CSSStyleRule: styleMap property

Baseline 2026
Newly available

Since November 2026, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Want more browser support for this feature? Tell us why.

The styleMap read-only property of the CSSStyleRule interface returns a StylePropertyMap object which provides access to the rule's property-value pairs.

Value

A StylePropertyMap object.

Example

The following example shows styleMap being used to modify a style using the StylePropertyMap.set() method.

js
const stylesheet = document.styleSheets[0];

Object.values(stylesheet.cssRules).forEach((block) => {
  if (block.selectorText === "button") {
    block.styleMap.set("--main-color", "black");
  }
});

Specifications

Specification
CSS Typed OM Level 1
# dom-cssstylerule-stylemap

Browser compatibility