Class selector

Matches the class property of the specified element.

Syntax

.value{sRules }

Possible values

value

String that specifies the value of the class attribute.

sRules

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

Remarks

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.

Example

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":

<style>
    h2.pastoral.marine {color: lightseagreen;}
</style> 

Standards information

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

See also

Concepts

Understanding selectors
Equality attribute selector
Existence attribute selector
Hyphen attribute selector
ID selector
Prefix attribute selector
Substring attribute selector
Suffix attribute selector
Type selector
Universal selector
Whitespace attribute selector

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