CSS counter-reset Property
The counter-reset property in CSS is used to create and initialize a counter that can be used with the counter-increment and content properties to generate automatic numbering (e.g., for lists, headings, or sections).
1. Syntax
✅ The counter is reset to the specified value (default is 0).
Value Options:
-
counter-name– The name of the counter to reset. -
number(optional) – The starting value (default is0).
2. Example – Simple Counter for Headings
✅ Each <h2> will be automatically numbered:
Section 1: Heading
Section 2: Another Heading
3. Example – Nested Numbering (Multi-Level Counter)
✅ Output for <h2> and <h3>:
4. Example – Numbering List Items
✅ Each <li> will be numbered automatically like an ordered list.
5. Example – Using Multiple Counters
✅ This creates two separate counters, one for <h1> (main counter) and one for <h2> (subsection counter).
6. Best Practices
✔ Use counter-reset at the parent level to ensure numbering resets correctly.
✔ Combine with counter-increment to create structured numbering.
✔ Use nested counters for hierarchical numbering.
✔ Counters only work with content in ::before or ::after pseudo-elements.

