Back to Content

CSSPropertyRule

files/en-us/web/api/csspropertyrule/index.md

latest1.4 KB
Original Source

{{APIRef("CSS Properties and Values API")}}

The CSSPropertyRule interface of the CSS Properties and Values API represents a single CSS {{cssxref("@property")}} rule.

{{InheritanceDiagram}}

Instance properties

Inherits properties from its ancestor {{domxref("CSSRule")}}.

  • {{domxref("CSSPropertyRule.inherits")}} {{ReadOnlyInline}}
    • : Returns the inherit flag of the custom property.
  • {{domxref("CSSPropertyRule.initialValue")}} {{ReadOnlyInline}}
    • : Returns the initial value of the custom property.
  • {{domxref("CSSPropertyRule.name")}} {{ReadOnlyInline}}
    • : Returns the name of the custom property.
  • {{domxref("CSSPropertyRule.syntax")}} {{ReadOnlyInline}}
    • : Returns the literal syntax of the custom property.

Instance methods

No specific methods; inherits methods from its ancestor {{domxref("CSSRule")}}.

Examples

This stylesheet contains a single {{cssxref("@property")}} rule. The first {{domxref("CSSRule")}} returned will be a CSSPropertyRule with the properties and values as defined by the rule in CSS.

css
@property --property-name {
  syntax: "<color>";
  inherits: false;
  initial-value: #c0ffee;
}
js
const myRules = document.styleSheets[0].cssRules;
console.log(myRules[0]); // A CSSPropertyRule

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}