A CSS counter is a little number keeper for generated content. It can automatically count items so a list gets custom numbers instead of relying on the browser’s usual markers. section 19.20
The basic idea comes in a few small steps:
- Remove the standard markers from an ordered list with list-style-type: none. section 19.20
- Use counter-increment to advance the number for each list item. section 19.20
- Use a pseudo-element such as ol::before to display custom numbers. section 19.20
Make a list count its own way
Start with an ordered list, hide its normal markers, and place generated numbers before the items. This gives you a starting point for styling the numbers as circles, stars, arrows, or another visual design. section 19.20
Counters are useful when numbering is part of the design rather than a fixed browser decoration. Try changing the marker shape or pairing the numbers with a themed list. section 19.20
