CSS/Selectors/class selector

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

CSS defines the class selector in 6.4. Class selectors.

Last modified on 22 July 2011, at 14:05