CSS element.classSelectors

Complete CSS Selector Reference Manual

Example

Select all <p> elements with class="hometown" and set the background color to yellow:

p.hometown { background-color:yellow; }

Try it Yourself »

Definition and Usage

element.classA selector is a way of combining an element selector and a class selector to select a specific HTML element with a specific class attribute.

Reference.class selector。


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support itelement.classSelector.


Complete CSS Selector Reference Manualother extensions