CSSLayerStatementRule: nameList-Eigenschaft

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.

Die schreibgeschützte nameList-Eigenschaft der CSSLayerStatementRule-Schnittstelle gibt die Liste der zugehörigen Kaskadenschicht-Namen zurück. Die Namen können nicht geändert werden.

Wert

Ein Array von Zeichenfolgen, von denen jede eine Kaskadenschicht repräsentiert, die durch die @layer-Statement-Regel dargestellt wird.

Beispiele

HTML

html
<div></div>

CSS

css
@layer layerName, layerName2;

@layer layerName3 {
  div {
    font-family: serif;
  }
}

JavaScript

js
const item = document.getElementsByTagName("div")[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 layerStatementRule = rules[0]; // A CSSLayerStatementRule
const layerBlockRule = rules[1]; // A CSSLayerBlockRule; no nameList property.

item.textContent = `@layer declares the following layers: ${layer.nameList.join(
  ", ",
)}.`;

Spezifikationen

Specification
CSS Cascading and Inheritance Level 5
# dom-csslayerstatementrule-namelist

Browser-Kompatibilität

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
nameList

Legend

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

Full support
Full support

Siehe auch