CSS .class Selector

❮ Previous Selectors Next ❯

Example

.example1 { 
  background-color: red;
}

.example2 { 
  background-color: green;
}

.example3 { 
  background-color: pink;
}

Meaning

The .class selector selects all tags with the specified class value.

Note: Whitespace characters can’t appear after the period, or between an element type selector, or explicit universal selector, and the period.

Version: CSS1




Standard Syntax

.className {
  css declarations;
}



Browser Support

The numbers in the table specify the first browser version that fully supports the property.




Status







More Examples

Example

p.example1 { 
  background-color: red;
}

p.example2 { 
  background-color: green;
}

div.example3 { 
  background-color: pink;
}
❮ Previous Selectors Next ❯