This page is Ready to Use

Notice: The WebPlatform project has been discontinued when the Stewards partnership agreement ended in September 2015. This site has been frozen, and the assets we have created will remain.

class

Summary

Styles all elements with the specified class.

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>

Notes

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.

Syntax

<strong/>sel.value {...}

Parameters

sel
Selector
value
String that specifies the value of the “class” attribute.

Standards information

Related specifications

CSS Level 2 Specification
W3C Recommendation

Attributions