ID selector in CSS

In CSS, id is used to style the element with the specified id.

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 :

  1. ID can be used with any HTML element.
  2. ID names are only allowed to contain letters, numbers, underscores _ , hyphens - . ID names should not begin with numbers
  3. ID values ​​are case sensitive.
  4. ID value must contain at least 1 character and no spaces.

For example:







TECHNOLOGY VILLAGE


TECHNOLOGY


SCIENCE - LIFE



Result:

ID selector in CSS Picture 1ID selector in CSS Picture 1

See more:

  1. Learn Basic CSS
  2. Learn Advanced CSS
4.5 ★ | 2 Vote