CSS .class Selector

The class selector is the most useful of all CSS selectors. It’s declared with a dot preceding a string of one or more characters. Just as is the case with an ID selector, this string of characters is defined by the developer. The class selector also matches all elements on the page that have their class attribute set to the same value as the class, minus the dot.

.class {
    css declarations;
.intro {
   color: #3366ff;
   background: #ffff99;

In this example, the elements with the class .intro will have their color and background styles changed.

Click the button below to experiment with this selector.

Give it a Try!

YesFirefox YesExplorer YesChrome YesSafari YesOpera