The CSSStyleDeclaration interface represents an object that is a CSS declaration block, and exposes style information and various style-related methods and properties.

A CSSStyleDeclaration object can be exposed using three different APIs:

  • Via ElementCSSInlineStyle.style, which deals with the inline styles of a single element (e.g., <div style="...">).
  • Via the CSSStyleSheet API. For example, document.styleSheets[0].cssRules[0].style returns a CSSStyleDeclaration object on the first CSS rule in the document's first stylesheet.
  • Via Window.getComputedStyle(), which exposes the CSSStyleDeclaration object as a read-only interface.


Textual representation of the declaration block. Setting this attribute changes the style.
CSSStyleDeclaration.lengthRead only
The number of properties. See the item() method below.
CSSStyleDeclaration.parentRuleRead only
The containing CSSRule.

CSS Properties

Special alias for the float CSS property.
CSSStyleDeclaration named properties
Dashed and camel-cased attributes for all supported CSS properties.


Returns the optional priority, "important".
Returns the property value given a property name.
Returns a CSS property name by its index, or the empty string if the index is out-of-bounds.
An alternative to accessing nodeList[i] (which instead returns undefined when i is out-of-bounds). This is mostly useful for non-JavaScript DOM implementations.
Removes a property from the CSS declaration block.
Modifies an existing CSS property or creates a new CSS property in the declaration block.
CSSStyleDeclaration.getPropertyCSSValue()  This deprecated API should no longer be used, but will probably still work.
Only supported via getComputedStyle in Firefox. Returns the property value as a CSSPrimitiveValue or null for shorthand properties.


var styleObj = document.styleSheets[0].cssRules[0].style;

for (var i = styleObj.length; i--;) {
  var nameString = styleObj[i];



Specification Status Comment
CSS Object Model (CSSOM)
The definition of 'CSSStyleDeclaration' in that specification.
Working Draft Merged the DOM Level 2 Style CSS2Properties interface into CSSStyleDeclaration.
Document Object Model (DOM) Level 2 Style Specification
The definition of 'CSSStyleDeclaration' in that specification.
Obsolete Initial definition

Browser compatibility

BCD tables only load in the browser

See also