CSS .class Selector

Complete CSS Reference Complete CSS Reference

Example

How to select all elements that has the class "intro":

.intro
{
background-color:yellow;
}

Try it yourself »

Definition and Usage

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


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The .class selector is supported in all major browsers.


CSS Version

The .class selector was first introduced in:

CSS 1


Examples

Try it Yourself - Examples


Example

How to style all <p> elements with class="hometown":

p.hometown
{
background-color:yellow;
}

Try it yourself »

Complete CSS Reference Complete CSS Reference