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
4.5 ★ | 2 Vote
You should read it
May be interested
- Class selector in CSSin css, class is used to style the element with the specified class.
- Deeply understand Color in CSScss supports up to 140 colors with unique names and lots of colors under the values of hex, rgb, rgba, hsl, hsla.
- Unit - Unit of measurement in CSScss supports a lot of length measurement units, also called units, to apply to attributes that need it.
- Gradient - color linear transformation in CSSthe gradient allows the creation of colored background elements, which are the transition effects between two or more specified colors.
- Shadow effect in CSSthe shadow attribute in css is used to set the shadow for the element elements in the website.
- Some properties to handle Text in CSSlearn how to handle text too long, causing overflow of the element that contains it.