Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML class Attribute

HTML class Attribute

HTML Global Attributes HTML Global Attributes

Example

Using the class attribute in an HTML document:

Runoob Tutorial(runoob.com)

Heading 1

A paragraph.

Note: This is a very important paragraph. :)

Try it »

More examples follow later in this chapter.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the class attribute


Definition and Usage

The class attribute defines a class name for an element.

The class attribute is often used to point to a class in a style sheet. However, it can also be used in JavaScript (through the HTML DOM) to change the class name of an HTML element.


Differences between HTML 4.01 and HTML5

In HTML5, the class attribute can be used on any HTML element (it will validate any HTML element, but it may not be useful).

In HTML 4.01, the class attribute cannot be used on: , , , , ,