CSSPropertyRule: name プロパティ

Baseline 2024
Newly available

Since July 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

nameCSSPropertyRule インターフェイスの読み取り専用プロパティで、これはプロパティ名を表します。これは @property ルールの前置き部分においてカスタムプロパティに指定された名前をシリアライズしたものです。

文字列です。

このスタイルシートには、単一の @property ルールが格納されています。最初に返される CSSRule は、このルールを表す CSSPropertyRule となります。 name プロパティは文字列 "--property-name" を返します。この文字列は、 CSS でカスタムプロパティに指定された名前です。

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

仕様書

Specification
CSS Properties and Values API Level 1
# dom-csspropertyrule-name

ブラウザーの互換性

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
name

Legend

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

Full support
Full support