Class (.) selector
Matches the class attribute of the specified element.
![]() |
Syntax
sel.value {...}
Parameters
- sel
-
Selector
- value
-
String that specifies the value of the "class" attribute.
Standards information
- CSS 2.1, Section 1.4
Remarks
The CLASS attribute value must immediately follow the "period" (.) notation. More than one class name can be specified in one style rule; to match a subset of CLASS values, each value must be preceded by a period.
Examples
For example, the following style rule matches any P element whose CLASS attribute has been assigned a space-separated list of values that include the "pastoral" and "marine" class names. This rule matches when class="pastoral aqua marine" but does not match when class="pastoral blue".
<style>
P.pastoral.marine { color: lightseagreen; }
</style>
Show:
