O'Reilly logo

CSS Pocket Reference, 4th Edition by Eric A. Meyer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Class Selector

Pattern:

element1.classname
element1.classname1.classname2

Description:

In languages that permit it, such as HTML, XHTML, SVG, and MathML, a class selector using “dot notation” can be used to select elements that have a class attribute containing a specific value or values. The name of the class value must immediately follow the dot. Multiple class values can be chained together, although there are support problems in Internet Explorer previous to IE7. If no element name precedes the dot, the selector matches all elements bearing that class value or values.

Examples:

p.urgent {color: red;}
a.external {font-style: italic;}
.example {background: olive;}
.note.caution {background: yellow;}

Note:

Internet Explorer previous to IE7 does not support the chained selector syntax, though it does permit multiple words in class values in the markup.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required