このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

CSSCounterStyleRule: name プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2023年9月.

nameCSSCounterStyleRule インターフェイスのプロパティで、関連付けられたルールの name として定義された <custom-ident> を取得または設定します。

文字列です。

次の例は @counter-style ルールを示しています。 JavaScript では myRules[0] がこの @counter-style ルールであり、 name を返すとカスタム識別子 "box-corner" という値が得られます。

css
@counter-style box-corner {
  system: fixed;
  symbols: ◰ ◳ ◲ ◱;
  suffix: ": ";
  fallback: disc;
}
js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].name); // "box-corner"

仕様書

Specification
CSS Counter Styles Level 3
# dom-csscounterstylerule-name

ブラウザーの互換性