MDN self-hosted library · e01.org
CSSScopeRule / notebook

CSSScopeRule

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

css
@scope (.outer) to (.inner) {
  :scope {
    background: yellow;
  }
}
js
const scopeBlock = document.styleSheets[0].cssRules[0];

console.log(scopeBlock.start); // Returns ".outer"
console.log(scopeBlock.end); // Returns ".inner"