ID Selector

Pattern:

element1#idValue

Description:

ID selector using "hash notation" to refer an ID. ID selector selects elements by its ID value.

The name of the ID value must immediately follow the #. If no element name precedes the octothorpe, then the selector matches all elements containing that ID value.

Examples:


h1#page-title {font-size: 250%;} 
body#home {background: silver;} 
#example {background: lime;}
Home 
  HTML CSS Book 
    CSS Reference  

Selector:
  1. Universal Selector
  2. Type Selector
  3. Descendant Selector
  4. Child Selector
  5. Adjacent Sibling Selector
  6. Class Selector
  7. ID Selector
  8. Simple Attribute Selector
  9. Exact Attribute Value Selector
  10. Partial Attribute Value Selector
  11. Hyphen-separated Attribute Value Selector
  12. !important
Related: