Element.className (Property)

The value of the CLASS tag attribute for the HTML tag that represents this element.

Availability:

DOM level - 1
JavaScript - 1.5
JScript - 3.0
Internet Explorer - 4.0
Netscape - 6.0
Property/method value type:String primitive
JavaScript syntax:-myElement.className
-myElement.className = aClassName
Argument list:aClassNameA new class name that exists in the cascading style sheet

This property contains the name of the cascading style sheet class for the tag that the Element object represents. Because MSIE implements its tag objects so consistently as sub-classes of the Element object class, it is possible to apply CLASS tag attributes to tags that really shouldn't have style sheets associated with them. The <HTML> and <HEAD> tags for example. Nevertheless, you can still define a CLASS tag attribute and its value will be reflected and accessible in this property.

You can read or write this value to manipulate the style attributes of the object.

The value is specified as a String primitive, but is case sensitive. If you specify multiple items, they must be space separated.

Changing this value can be a way to change a whole range of style settings on an object in a single hit rather than modifying the individual settings one by one.

Warnings:

See also:CLASS="...", Element object