This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

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