Class Selector

Pattern:


element1.classname 
element1.classname1.classname2

Description:

A class selector uses dot notation to refer a class name. A class selector selects elements by its class name.

The name of the class value must immediately follow the dot. Multiple class values can be chained together. If no element name precedes the dot, the selector matches all elements containing that class value.

Examples:


p.urgent {color: red;} 
a.external {font-style: italic;} 
.example {background: olive;} 
.note.caution {background: yellow;}
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: