You are here: Reference > HTML > attributes > class

class attribute

Browser support:
Sets the style class or classes that belong to the element.
With this attribute you can assign Cascading Style Sheets (CSS) declarations to an element.
CSS is useful for adding styling behaviors to an element. For a complete list of style properties, please see the page for CSS properties.
JavaScript page for this attribute: className. You can find other example(s) there.

Possible values:

String that sets a space-separated list of the related class names.
Default: this attribute has no default value.

Example HTML code 1:

This example illustrates the use of the class attribute:
        .text {color: red;}
    <p class="text" id="myP">
        This text is red.
Did you find this example helpful? yes no

Supported by tags:

External links:

User Contributed Comments

Post Content

Post Content