CSSLayerBlockRule

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2022.

The CSSLayerBlockRule represents a @layer block rule.

CSSRule CSSGroupingRule CSSLayerBlockRule

Instance properties

Inherits properties from its ancestors CSSGroupingRule and CSSRule.

Instance methods

Inherits methods from its ancestors CSSGroupingRule and CSSRule.

Examples

HTML

html
<p>I am displayed in <code>color: rebeccapurple</code>.</p>

CSS

css
@layer special {
  p {
    color: rebeccapurple;
  }
}

JavaScript

js
const item = document.getElementsByTagName("p")[0];
const rules = document.styleSheets[1].cssRules;
// Note that stylesheet #1 is the stylesheet associated with this embedded example,
// while stylesheet #0 is the stylesheet associated with the whole MDN page

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

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

Result

Specifications

Specification
CSS Cascading and Inheritance Level 5
# csslayerblockrule

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
CSSLayerBlockRule
name

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also