CSSStyleRule: styleMap property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
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("--mainColor", "black");
}
});
Specifications
Specification |
---|
CSS Typed OM Level 1 # dom-cssstylerule-stylemap |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
styleMap |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.