In an HTML document, the CSS ID selector will match the elements according to the contents in the ID attribute of the elements, and the ID attribute name of the elements must exactly match the ID attribute name in the selector before this style declaration will take effect. The syntax is as follows:
#id attribute {style declaration}
Extended data
Css cascading style sheets have ID selectors, element selectors and class selectors.
1, example of ID selector in css cascading style sheet:
& ltdiv? Id= "search"? & gt& lt/div & gt;
& ltstyle & gt# Search? {? Floating:? Right; ? Width:? 305px? Height:? 76px} & lt/style & gt;
2. Syntax and examples of element selectors in 2.css cascading style sheets.
Syntax: Element {Style Declaration}
Example:
& lt style & gt span {background-color: dodger blue; Color: # ffffff} & lt/style & gt;;
3. Syntax and examples of class selectors in 3.css cascading style sheets.
Grammar:. Class name {style declaration}
Example:
& ltstyle & gt。 Search {background-color: dodgerblue; } & lt/style & gt;