CSSLayerBlockRule
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("CSSOM")}}
The **CSSLayerBlockRule** represents a {{cssxref("@layer")}} block rule.
{{InheritanceDiagram}}
Instance properties
_Inherits properties from its ancestors {{domxref("CSSGroupingRule")}} and {{domxref("CSSRule")}}._
- {{DOMxRef("CSSLayerBlockRule.name")}} {{ReadOnlyInline}}
- : A string containing the name of the associated cascade layer.
Instance methods
_Inherits methods from its ancestors {{domxref("CSSGroupingRule")}} and {{domxref("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.getElementById("css-output").sheet.cssRules;
const layer = rules[0]; // A CSSLayerBlockRule
item.textContent = `The CSSLayerBlockRule is for the "${layer.name}" layer`;Result
{{EmbedLiveSample("Examples")}}
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
- {{cssxref("@layer")}}
- {{DOMxRef("CSSLayerStatementRule")}}
- Learn CSS cascade layers