interface
Cssscoperule — CSS reference
Represents an at-scope rule, with serialized scope start and optional scope end selectors. Its child rules remain in a grouping rule. A scoped declaration applies within the scope root and outside any excluded scope limit.
Formal Syntax & Structure
css syntaxcss
rule.start; rule.end; rule.cssRulesWorking Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSSScopeRule</title><style>body{margin:8px;font:16px/20px sans-serif;color:black;background:white}@scope (.region) to (.limit){p{color:blue}}</style><body><section class="region"><p id="a">Included</p><section class="limit"><p id="outside">Excluded</p></section></section><p>Run once, then reload the page to repeat from the original state.</p><button id="run" type="button">Run example</button><pre id="result" aria-live="polite"></pre><script>const target=document.getElementById('a');const sheet=document.styleSheets[0];async function demo(){const r=sheet.cssRules[1];return [r instanceof CSSScopeRule,r.start,r.end,getComputedStyle(target).color,getComputedStyle(document.getElementById("outside")).color];}document.getElementById('run').onclick=async()=>{try{document.getElementById('result').textContent=JSON.stringify(await demo());}catch(e){document.getElementById('result').textContent=e.name+': '+e.message;}};</script></body></html>