Custom Counter Styles With @counter-style
Defining your own numbering with @counter-style: cyclic, fixed, symbolic, alphabetic, numeric and additive systems, prefix and suffix, range and fallback, negative and pad, extending built-in styles, speak-as, and symbols().
kvi5hnuCode Sprout team member7 min readOn this page
The built-in counter styles cover dozens of scripts, but sometimes you need something else: emoji bullets, "Step 01", hexadecimal, a marker that cycles through shapes, or numbering with a custom suffix. @counter-style defines a new style by name, which then works anywhere a counter style does: list-style-type, counter() and counters().
@counter-style step {
system: extends decimal;
prefix: "Step ";
suffix: ": ";
pad: 2 "0";
}
ol.steps { list-style-type: step; } /* Step 01: Step 02: … */
h3::before { content: counter(h3, step); } /* also in counter() */
@counter-style works in all browsers since Safari 17.
Systems
The system descriptor sets the algorithm that turns a number into a marker, and symbols lists the symbols it uses, separated by spaces. Quoting symbols is safest, especially for punctuation.

system | How it counts | Good for |
|---|---|---|
cyclic | uses the symbols in order, then repeats | bullets that alternate shapes, a single custom bullet |
fixed | uses each symbol once, then falls back; fixed 5 starts at 5 | a fixed set, like circled numbers ① to ⑩ |
symbolic | after running out, doubles, then triples each symbol | footnote marks: *, †, **, †† |
alphabetic | treats symbols as digits with no zero, like spreadsheet columns | custom alphabets; needs at least two symbols |
numeric | positional, with the first symbol as zero; the number of symbols is the base | binary, hexadecimal, other digit sets |
additive | adds up weighted symbols, from additive-symbols | Roman-style numbering, tally marks, dice |
All the results in the diagram were rendered in Chrome. A few details from those tests:
- With
fixed 5and three symbols, values 5, 6 and 7 used the symbols, and 4 and 8 fell back to decimal. - A hexadecimal
numericstyle, with symbols'0'to'F', showed F, 10, FF and 100 for 15, 16, 255 and 256. - An
alphabeticstyle with one symbol is invalid, and the whole rule is ignored: the list showed plain decimal.
Additive systems
additive-symbols lists weights with their symbols, largest first. The algorithm repeatedly takes the largest symbol that fits:
@counter-style tally {
system: additive;
additive-symbols: 5 "卌", 1 "|"; /* groups of five, then single strokes */
suffix: " ";
}
With this style, 7 is 卌||. Tested in Chrome: a dice style with weights 6 down to 1 showed 15 as ⚅⚅⚂. Because the algorithm always takes the largest symbol first, some values can't be built even when it seems they could: with only 3 Y, 2 X, 4 can't be shown (3 leaves 1, which no symbol covers), and the value falls back to decimal. Include a weight of 1, or 0 for zero, to avoid gaps.
Descriptors
| Descriptor | Default | Effect |
|---|---|---|
prefix | "" | text before every marker |
suffix | ". " | text after every marker; set suffix: " " to remove the period |
range | auto | the values the style handles, as pairs: range: 1 20, 100 infinite; others use the fallback |
fallback | decimal | the style for values outside the range or not representable |
negative | "-" | text around negative values: negative: "(" ")" for accounting style |
pad | 0 "" | minimum length, and the symbol to pad with: pad: 3 "0" gives 001 |
speak-as | auto | how screen readers announce the marker |
Tested in Chrome:
- A
cyclicstyle with nosuffixshowed "→. ", with the default period. - A style limited to
range: 1 3withfallback: lower-alphagave I, II, III, d, e, f, still using the original style's suffix. negative: "(" ")"showed −2 as (2).pad: 3 "0"gave 001, 002. Padding is a minimum: 1000 stayed 1000, and the negative sign counts toward the padded length, so −5 showed as -05.
Extending existing styles
system: extends <name> reuses another style's algorithm and symbols, and changes only the other descriptors:
@counter-style decimal-paren { system: extends decimal; suffix: ") "; }
@counter-style roman-short { system: extends upper-roman; range: 1 39; fallback: decimal; }
@counter-style padded-octal { system: extends octal; pad: 4 "0"; } /* extends another custom style */
An extends style can't have symbols or additive-symbols. Tested in Chrome: system: extends decimal; symbols: a b made the rule invalid, and the list fell back to plain decimal with a period.

None of these cases produces an error. The two red panels on the left look exactly like an unstyled list, because an invalid @counter-style rule is dropped and list-style-type falls back to decimal. In the additive panel, 1 and 4 fall back too, but they keep the custom style's suffix. When a custom style seems to be ignored, check the rule for one of these mistakes before you suspect the selector.
Accessibility: speak-as
Screen readers announce markers. A marker made of emoji or dice may be read in a confusing way, like "die face 6, die face 6, die face 3", or a tally read as a list of strokes. speak-as says how to announce it:
| Value | Announced as |
|---|---|
auto | depends on the system: like bullets for cyclic, spell-out for alphabetic, otherwise numbers |
numbers | the number, in the document's language: "fifteen" |
bullets | like a bullet in an unordered list, often nothing |
words, spell-out | the marker text as words, or letter by letter |
| a style name | as if it were that style, like speak-as: decimal |
@counter-style tally { speak-as: numbers; system: additive; additive-symbols: 5 "卌", 1 "|"; }
speak-as works in Chrome and Firefox, not Safari. Markers that look decorative but carry order should still be announced as numbers.
Inline styles: symbols()
For a one-off style, the symbols() function defines an anonymous style inline, with a system and symbols, but no other descriptors:
ul.suits { list-style-type: symbols(cyclic "♠" "♣" "♥" "♦"); }
It works in Firefox and in Chrome since 155; Safari doesn't support it yet. A named @counter-style works everywhere and also lets you set the suffix.
@counter-style step { system: extends decimal; prefix: "Step "; suffix: " · "; pad: 2 "0"; }
@counter-style suits { system: cyclic; symbols: "♠" "♣" "♥" "♦"; suffix: " "; }
@counter-style octal { prefix: "0o"; suffix: " "; system: numeric; symbols: "0" "1" "2" "3" "4" "5" "6" "7"; }
@counter-style notes { system: symbolic; symbols: "*" "†" "‡"; suffix: " "; }
@counter-style dice { suffix: " "; speak-as: numbers; system: additive;
additive-symbols: 6 "⚅", 5 "⚄", 4 "⚃", 3 "⚂", 2 "⚁", 1 "⚀"; }
@counter-style ledger { system: extends decimal; negative: "(" ")"; suffix: " "; }
body { font: 0.85rem/1.5 system-ui, sans-serif; margin: 1rem; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem 1rem; }
ol, ul { margin: 0; padding-inline-start: 3.6rem; background: #f4efe6; border-radius: 6px; padding-block: 0.3rem; }
li::marker { color: #8a3b12; font-weight: 700; }
.steps { list-style-type: step; padding-inline-start: 4.6rem; }
.suits { list-style-type: suits; padding-inline-start: 1.8rem; }
.octal { list-style-type: octal; }
.notes { list-style-type: notes; padding-inline-start: 2.4rem; }
.dice { list-style-type: dice; font-size: 0.9rem; }
.ledger { list-style-type: ledger; }
octal counts 0o6, 0o7, 0o10, 0o11; notes goes *, †, ‡, then doubles; dice adds up faces, so 7 is ⚅⚀; and ledger shows negatives in parentheses.
What's current
@counter-style: all browsers since Safari 17.speak-as: Chrome and Firefox.symbols(): Firefox and Chrome 155; not Safari yet.
Common questions
How do I remove the period after list numbers?
Define a style that extends decimal with suffix: " ", or use ::marker { content: counter(list-item) " " }.
Why is my @counter-style ignored?
The rule is invalid: for example extends with symbols, an alphabetic or numeric system with fewer than two symbols, or additive without additive-symbols.
Why does my additive style show plain numbers for some values? Those values can't be built from the weights with the largest-first algorithm. Add a weight of 1.
Will screen readers read emoji markers?
Probably, as their names. Use speak-as: numbers (or bullets) where supported.
Summary
@counter-style name { … }defines a style usable inlist-style-typeandcounter().- Systems:
cyclicrepeats,fixedruns out,symbolicmultiplies,alphabeticandnumericare positional,additivesums weights. prefix,suffix(default ". "),range,fallback,negativeandpadshape the output.extendsreuses a style's symbols and changes only descriptors.speak-ascontrols screen reader announcement;symbols()makes simple anonymous styles.
Practice questions
Write a counter style that shows "(a)", "(b)", "(c)" for legal sub-clauses.
Answer
@counter-style paren-alpha { system: extends lower-alpha; prefix: "("; suffix: ") "; }
ol.clauses { list-style-type: paren-alpha; }
A style uses system: fixed; symbols: "①" "②" "③";. What do items 4 and 5 show?
Answer
"4. " and "5. ": a fixed system has no symbols left after 3, so the values fall back to decimal, with the style's default ". " suffix.
Why is this rule invalid?
@counter-style letters { system: extends decimal; symbols: "a" "b" "c"; }
Answer
An extends style reuses the base style's symbols and can't define symbols or additive-symbols. Use system: alphabetic (or cyclic) with those symbols instead.
Write a style for three-digit order numbers like "No. 007".
Answer
@counter-style order-no { system: extends decimal; prefix: "No. "; suffix: " "; pad: 3 "0"; }
Review quiz
Test yourself on Part 13 with the CSS Part 13 review quiz.
Previous: CSS Counters: counter-reset, counter-increment and Nested Numbering
Next: Filters: blur(), drop-shadow(), Color Filters and backdrop-filter

More in CSS Course
Quiz: CSS Delicate Details
Twenty-five questions on the edge cases that surprise experienced developers: invalid custom properties, shorthands that reset values, layer order with !important, containing blocks, margin collapsing, specificity of :is() and :where(), intrinsic minimum sizes, and more, each checked in Chrome.
Quiz: CSS Interview Questions
Thirty front-end interview questions: cascade, specificity and layers, box model and margin collapsing, stacking contexts, positioning, flexbox and grid, responsive design, custom properties, performance, accessibility, modern selectors and architecture.
Quiz: CSS Course Final Exam
Thirty questions across the whole CSS course: syntax and error handling, selectors, the cascade and layers, values and units, color, the box model, backgrounds, positioning, flexbox, grid, responsive design, typography, generated content, effects, transforms, motion and architecture.
Quiz: CSS Architecture, Tooling and Debugging (CSS Part 17)
Twenty questions on modular CSS and BEM, layering a stylesheet, design tokens and theming, pattern libraries and safe refactoring, preprocessors and build tools, the at-rules reference, and debugging common CSS problems.
Discussion
Sign in to ask a question or share what you learned.