CSS .class Selector


Example

Select and style all elements with class="intro":

.intro {
    background-color: yellow;
}

Try it yourself »

More "Try it Yourself" examples below.


Definition and Usage

The .class selector styles all elements with the specified class.

Version: CSS1

Browser Support

Selector
.class Yes Yes Yes Yes Yes

CSS Syntax

.class {
    css declarations;
} Demo

Examples

More Examples


Example

Style all <p> elements with class="hometown":

p.hometown {
    background-color: yellow;
}

Try it yourself »




SHARE THIS PAGE

Color Picker

colorpicker