CSS3/Selectors/class selector

From W3C Wiki
Jump to: navigation, search

Class Selector

Class selector represents an element with the class attribute whose value is a whitespace-separated list of words, one of which is exactly "classname". It's same meaning [class~=value].


.classname{ properties }



   color: green;
   font-size: 0.9em;


  <h1>Not green</h1>
  <h1 class="pastoral">green and small font-size.</h1>
  <p class="pastoral">green, but not change the font-size.</p>

Css3 selectors class.png

The CSS Selectors Level 3 specification defines the class selector in 6.4. Class selectors.