CSSPropertyRule.initialValue
initialValue は CSSPropertyRule インターフェイスの読み取り専用プロパティで、 null にすることができます。 @property ルールで表されるカスタムプロパティ登録の初期値を返し、プロパティの初期値を制御します。
値
文字列で、 CSS 構文 3 で定義されている <declaration-value> です。
例
このスタイルシートには、単一の @property ルールが格納されています。最初に返される CSSRule は、このルールを表す CSSPropertyRule となります。 initialValue プロパティは、文字列 "#c0ffee" を返します。これは、 CSS の initial-value プロパティの値です。
css
@property --property-name {
syntax: '<color>';
inherits: false;
initial-value: #c0ffee;
}
js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].initialValue); //the string "#c0ffee"
仕様書
| Specification |
|---|
| CSS Properties and Values API Level 1 # dom-csspropertyrule-initialvalue |
ブラウザーの互換性
BCD tables only load in the browser