CSSPropertyRule
Baseline 2024Newly available
Since July 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
TheCSSPropertyRule interface of theCSS Properties and Values API represents a single CSS@property rule.
In this article
Instance properties
Inherits properties from its ancestorCSSRule.
CSSPropertyRule.inheritsRead onlyReturns the inherit flag of the custom property.
CSSPropertyRule.initialValueRead onlyReturns the initial value of the custom property.
CSSPropertyRule.nameRead onlyReturns the name of the custom property.
CSSPropertyRule.syntaxRead onlyReturns the literal syntax of the custom property.
Instance methods
No specific methods; inherits methods from its ancestorCSSRule.
Examples
This stylesheet contains a single@property rule. The firstCSSRule returned will be aCSSPropertyRule 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 CSSPropertyRuleSpecifications
| Specification |
|---|
| CSS Properties and Values API Level 1> # the-css-property-rule-interface> |