Easy Tutorial
❮ Prop Date Autofocus Prop Nav Platform ❯

CSSStyleDeclaration item() Method

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);

Definition and Usage

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


Browser Support

Method Chrome IE Firefox Safari Opera
item() Yes 9.0 Yes Yes Yes

Syntax

style.item(index)

Parameter 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

Loops through and outputs all property names of the element's style:

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

CSS CSSStyleDeclaration

❮ Prop Date Autofocus Prop Nav Platform ❯