CSS Selector Level 1 » Class

This class selector will match every element which has a certain class.

This selector is the same as the more complicate CSS2 attribute selector (Whitespace).

# Syntax

.classname {
    /* declarations */

# Example

.alert {
    border: 1px solid red;
    background-color: pink;

In this example will every element with the class of alert will get a red border with an pink background.

Try example in CodePen

# Browser support

Platform Chrome Firefox Safari Edge Internet Explorer Opera
Desktop Yes (1.0) Yes (1.0) Yes (1.0) Yes (12.0) Yes (3.0) Yes (2.0)
Mobile Yes (1.0) Yes (1.0) Yes (1.0) Yes (12.0) Yes (3.0) Yes (2.0)

Please wait a moment, the comments start loading now...