ID selector in CSS
In CSS, ID is used to style the element with the specified id. IDs are often used for objects that are unique in the website, each id name is unique to an element.
To declare ID in CSS, we use the following syntax:
#ten_id {
định dạng các thuộc tính CSS
}
For example:
#quantrimang {
background-color: black;
color: white;
font-size: 30px;
In HTML, the ID is open in the HTML tag with the syntax: id=ten_id .
For example:
Website TipsMake.com
Note :
- ID can be used with any HTML element.
- ID names are only allowed to contain letters, numbers, underscores
_, hyphens-. ID names should not begin with numbers - ID values are case sensitive.
- ID value must contain at least 1 character and no spaces.
For example:
TECHNOLOGY VILLAGE
TECHNOLOGY
SCIENCE - LIFE
Result:
See more:
- Learn Basic CSS
- Learn Advanced CSS
Discover more
css id
id attribute
id attribute in HTML
distinguish class and id in html
mark HTML page
Share by
Samuel Daniel
Update 27 May 2019