CSSStyleDeclaration item() Method

CSS CSSStyleDeclaration CSS CSSStyleDeclaration

Example

Returns the first property name of the style corresponding to the element with id ex1:

var style = document.getElementById("ex1").style; var propname = style.item(0); alert(propname);

Try it Yourself »

Definition and Usage

The item() method returns the property name at the specified index position in the CSS style, with index values starting from 0.


Browser Support

Method
item() Yes 9.0 Yes Yes Yes

Syntax

style.item(index)

Property Values

Parameter Description
index Required. A number representing the index position of the CSS style property.

Technical Details

DOM Version: CSS Object Model
Return Value: String, representing the property name.

More Examples

Example

Loop through all styles of an element and output the property names:

for (i = 0; i < elmnt.style.length; i++) { txt += elmnt.style.item(i) }

Try it Yourself »

CSS CSSStyleDeclaration CSS CSSStyleDeclaration

Other Extensions