Class selector

Class selector

Matches the class property of the specified element.


. value { sRules }

Possible values


String that specifies the value of the class attribute.


String that specifies one or more cascading style sheet property/value pairs.


The class property value must immediately follow a period (.). 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.


For example, the following style rule matches any H2 element whose class property 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":

    h2.pastoral.marine {color: lightseagreen;}

Standards information

This selector is defined in Cascading Style Sheets (CSS), Level 1 (CSS1) Ee371290.xtlink_newWindow(en-us,Expression.40).png.

See also

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.

Community Additions

© 2016 Microsoft