CSSStyleDeclaration: parentRule property - Web APIs | MDN

Value

The CSS rule that contains this declaration block or null if this CSSStyleDeclaration is not attached to a CSSRule.

Examples

The following JavaScript code gets the parent CSS style rule from a CSSStyleDeclaration:

js

const declaration = document.styleSheets[0].rules[0].style;
const rule = declaration.parentRule;

Specifications

Specification
CSS Object Model (CSSOM)
# dom-cssstyledeclaration-parentrule

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.