Since September 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
The @counter-style rule's prefix descriptor specifies content that will be added to the beginning of the counter's marker representation.
When the counter value is negative, the prefix comes before the negative sign and any other <symbol>s added by the negative descriptor.
/* <symbol> value: string, image, or identifier */
prefix: "»";
prefix: "Page ";
prefix: url("bullet.png");
The prefix descriptor takes as its value a single <symbol>:
<symbol>Specifies a <symbol> — a <string>, <image>, or <custom-ident> — that is prepended to the marker representation.
| Related at-rule | @counter-style |
|---|---|
| Initial value | "" (the empty string) |
| Computed value | as specified |
prefix =
<symbol>
<symbol> =
<string> |
<image> |
<custom-ident>
<image> =
<url> |
<gradient>
<url> =
<url()> |
<src()>
<url()> =
url( <string> <url-modifier>* ) |
<url-token>
<src()> =
src( <string> <url-modifier>* )
In this example, each counter number is prefixed by "Book " (with a space) and followed by a colon (:). The colon is added with the suffix descriptor.
<ol class="books"> <li>Flamer, by Mike Curato</li> <li>Gender Queer: A Memoir, by Maia Kobabe</li> <li>Tricks, by Ellen Hopkins</li> <li>The Handmaid's Tale: The Graphic Novel, by Margaret Atwood</li> <li>Crank, by Ellen Hopkins</li> </ol>
@counter-style books {
system: numeric;
symbols: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9";
prefix: "Book ";
suffix: ": ";
}
.books {
list-style: books;
padding-left: 15ch;
}
| Specification |
|---|
| CSS Counter Styles Level 3> # counter-style-prefix> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
prefix |
91 | 91 | 33 | 77 | 17 | 91 | 33 | 64 | 17 | 16.0 | 91 | 17 |
@counter-style descriptors: system, symbols, additive-symbols, negative, suffix, range, pad, speak-as, and fallback
list-style, list-style-image, list-style-position
symbols(): the functional notation for creating anonymous counter styles
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/@counter-style/prefix