HTML DOM className property
Definition and Usage
The className property sets or returns the class attribute of an element.
Syntax
Get the attribute value:
HTMLElementObject.className
Set the attribute value:
HTMLElementObject.className=
classname
Browser support





All major browsers support the className property
Example
Example
Return the class attribute of the body element:
Output result:
Body CSS class: mystyle
An alternate way: mystyle
Try it »
Element object