CSSScopeRule
The CSSScopeRule
interface of the CSS Object Model represents a CSS @scope
at-rule.
Instance properties
This interface inherits properties from its parent, CSSGroupingRule
.
Instance methods
This interface inherits methods from its parent, CSSGroupingRule
.
Examples
Accessing @scope information in JavaScript
Assuming the following is the only stylesheet attached to a document:
css
@scope (.outer) to (.inner) {
:scope {
background: yellow;
}
}
The following JavaScript could be used to access information about the contained @scope
block:
js
const scopeBlock = document.styleSheets[0].cssRules[0];
console.log(scopeBlock.start); // Returns ".outer"
console.log(scopeBlock.end); // Returns ".inner"
Specifications
Specification |
---|
CSS Cascading and Inheritance Level 6 # cssscoperule |
Browser compatibility
desktop | mobile | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CSSScopeRule | |||||||||||
end | |||||||||||
start |