CSSStyleDeclaration length Property
Example
Return the number of styles set on the H1 element:
var elmnt = document.getElementsByTagName("h1")[0];
var x = style.length;
Try it Yourself »
Description
The length property returns the number of style declarations set for 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: | A Integer, representing the number of style declaration set for the element |
More Examples
Example
Loop through all the element's style declarations:
for (i = 0; i < elmnt.style.length; i++) {
txt +=
elmnt.style.item(i)
}
Try it Yourself »
❮ CSSStyleDeclaration Object