CSSCounterStyleRule: prefix property

Baseline 2023

Newly available

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

The prefix property of the CSSCounterStyleRule interface gets and sets the value of the prefix descriptor. If the descriptor does not have a value set, this attribute returns an empty string.

Value

A string.

Examples

The following example shows a @counter-style rule. In JavaScript, myRules[0] is this @counter-style rule, returning prefix gives us the value "Chapter ".

css
@counter-style chapters {
  system: numeric;
  symbols: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9";
  prefix: "Chapter ";
}
js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].prefix); // "Chapter "

Specifications

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

Browser compatibility

BCD tables only load in the browser