CSS/Selectors/id selector

From W3C Wiki
< CSS‎ | Selectors
Jump to: navigation, search

ID Selector

The ID selector represents an element with the id attribute whose value is a whitespace-separated list of words, one of which is exactly "idname".

Syntax

#idname{ properties }


Point, Note

  • What makes attributes of type ID special is that no two such attributes can have the same value in a document.


Example

[style.css]

 #pastoral{
   color: green;
 }


[index.html]

<body>
  <h1>Not green</h1>
  <h1 id="pastoral">green</h1>
</body>

Css3 selectors id.png

CSS defines the ID selector in 6.5. ID selectors.