CSSStyleDeclaration
represents a collection of CSS property-value pairs. It is used in a few APIs:
HTMLElement.style
- to manipulate the style of a single element (<elem style="...">);style
property of a cssRule
in a stylesheet, when the rule is a CSSStyleRule.CSSStyleDeclaration
is also a read-only interface to the result of window.getComputedStyle().CSSStyleDeclaration.cssText
CSSStyleDeclaration.length
Read only
item()
method below.CSSStyleDeclaration.parentRule
Read only
CSSRule
.CSSStyleDeclaration.getPropertyPriority()
CSSStyleDeclaration.getPropertyValue()
CSSStyleDeclaration.item()
CSSStyleDeclaration.removeProperty()
CSSStyleDeclaration.setProperty()
CSSStyleDeclaration.getPropertyCSSValue()
CSSPrimitiveValue
or null
for shorthand properties.var styleObj = document.styleSheets[0].cssRules[0].style; console.log(styleObj.cssText); for (var i = styleObj.length; i--;) { var nameString = styleObj[i]; styleObj.removeProperty(nameString); } console.log(styleObj.cssText);
The declaration block is that part of the style rule that appears within the braces and that actually provides the style definitions (for the selector, the part that comes before the braces).
Specification | Status | Comment |
---|---|---|
CSS Object Model (CSSOM) The definition of 'CSSStyleDeclaration' in that specification. | Working Draft | |
Document Object Model (DOM) Level 2 Style Specification The definition of 'CSSPrimitiveValue' in that specification. | Obsolete | Initial definition |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration