DOM CSSStyleDeclaration Interface
CSSStyleDeclaration is an object of CSS properties and values, such as an element's inline style or the result of getComputedStyle().
Description
A CSSStyleDeclaration object represents a block of CSS declarations. You get one from an element's style property (its inline styles, which you can change), from getComputedStyle() (the final, read-only values the browser uses) and from CSS rules in style sheets.
Properties can be read and written in camelCase, style.backgroundColor, or with getPropertyValue() and setProperty() using CSS names, which is also how you work with custom properties such as --main-color.
The style object returned by getComputedStyle() is live: if styles change, reading a property again gives the new value. Properties can also be looped over by index, since the object has a length and numbered entries holding property names, and cssText gets or sets the whole declaration block as one string.
Methods
| Name | Description |
|---|---|
CSSStyleDeclaration.setProperty() | The setProperty() method sets a CSS property on a style object using its CSS name, which is how you set custom properties like --accent from JavaScript. |
Example
Browser Support
The following information will show you the current browser support for the CSSStyleDeclaration interface. Hover over a browser icon to see the version that first introduced support for this interface.
Desktop





Tablets & Mobile





