MDN self-hosted library · e01.org

CSSLayerBlockRule

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

html
<p>I am displayed in <code>color: rebeccapurple</code>.</p>
css
@layer special {
  p {
    color: rebeccapurple;
  }
}
js
const item = document.getElementsByTagName("p")[0];
const rules = document.getElementById("css-output").sheet.cssRules;

const layer = rules[0]; // A CSSLayerBlockRule

item.textContent = `The CSSLayerBlockRule is for the "${layer.name}" layer`;