Easy Tutorial
❮ Event Ontimeupdate Jsref Regexp Tostring ❯

CSSStyleDeclaration length Property

CSS CSSStyleDeclaration

Example

Return the number of style declarations for an h1 element:

var elmnt = document.getElementsByTagName("h1")[0];
var x = style.length;

Definition and Usage

The length property returns the number of style declarations for a specified element.


Browser Support

Property
length Yes Yes Yes Yes Yes

Syntax

Return the length property:

element.style.length

Technical Details

DOM Version: CSS Object Model
Return Value: Integer, representing the number of CSS declarations
--- ---

More Examples

Example

Loop through and output all inline CSS property names of a specified element:

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

CSS CSSStyleDeclaration

❮ Event Ontimeupdate Jsref Regexp Tostring ❯