CSS3/Selectors/id selector

From W3C Wiki

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>

The CSS Selectors Level 3 specification defines the ID selector in 6.5. ID selectors.