Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
HTML and CSS
CSS Reference
Selectors
 Class Selector

  Switch on low bandwidth view
Class Selector
Matches the class attribute of the specified element.

Syntax

HTML.value { sRules }
ScriptingN/A

Possible Values

valueString that specifies the value of the "class" attribute.
sRulesString that specifies one or more Cascading Style Sheets (CSS) attribute/value pairs.

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.

Example

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> 

Standards Information

This selector is defined in CSS, Level 1 (CSS1).

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker