CSSStyleDeclaration length Property

CSS CSSStyleDeclaration CSS CSSStyleDeclaration

Example

Return the number of declarations in the h1 element's style:

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

Try it Yourself »

Definition and Usage

The length property returns the number of style declarations of the 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: An integer, representing the number of CSS declarations

More Examples

Example

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

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

Try it Yourself »

CSS CSSStyleDeclaration CSS CSSStyleDeclaration

Other Extensions