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.cssTextCSSStyleDeclaration.lengthCSSStyleDeclaration.parentRuleCssRule.CSSStyleDeclaration.getPropertyPriority()CSSStyleDeclaration.getPropertyValue()CSSStyleDeclaration.item()CSSStyleDeclaration.removeProperty()CSSStyleDeclaration.setProperty()CSSStyleDeclaration.getPropertyCSSValue()ROCSSPrimitiveValue in Firefox (CSSPrimitiveValue, in others, which implements CSSValue), or null for Shorthand properties. Example: cssString= window.getComputedStyle(elem, null).getPropertyCSSValue('color').cssText;DOMException NOT_SUPPORTED_ERR.var styleObj= document.styleSheets[0].cssRules[0].style;
alert(styleObj.cssText);
for (var i = styleObj.length-1; i >= 0; i--) {
var nameString = styleObj[i];
styleObj.removeProperty(nameString);
}
alert(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).
© 2005–2017 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