CSS counter-reset Property

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The counter-reset property creates one or more named CSS counters and sets each to a starting value. A bare name starts at 0. After that, use counter-increment and print the value with content and counter().

The initial value is none. It is not inherited. Put the reset on a parent so every child shares the same counter scope.

Baseline · Widely available.

Basic named counters are not deprecated. The reversed() form is limited (mainly Firefox) — use a high start plus a negative increment for countdown in all browsers.

Name tip.

counter-reset creates and initializes a counter. counter-set jumps an existing counter to a value. Prefer reset for the first setup step.

CSS Syntax

syntax.css
counter-reset: [ <counter-name> <integer>? ]+ | none | initial | inherit;

List one or more counter names, each optionally followed by an integer. Omit the integer to start at 0.

Property Values

ValueDescriptionTry it
<counter-name>Creates that counter and sets it to 0Try it
name + integerCreates the counter and starts at that integer, such as section 2Try it
Negative integerStarts below zero, such as section -1Try it
New parent resetReset again on a nested parent to restart the same counter nameTry it
noneDo not create or reset any counters. Initial valueTry it
initialSets this property to its default value, noneTry it
inheritInherits this property from the parent elementTry it

How to Use counter-reset

Reset on a parent, increment on each item, then print with content.

  1. On a parent, set counter-reset: section (or another name, optionally with a start integer).
  2. On each child that should advance the count, set counter-increment: section.
  3. On ::before (or ::after), set content: counter(section).
  4. Use a new reset on a nested parent when a group should restart at the same start value.
PieceRequired?Role
counter-resetRecommendedCreates the counter and sets the start value
counter-incrementYesMoves the counter on each matching element
content: counter(...)To display itWrites the current value into generated content
IntegerOptionalDefaults to 0 for a regular counter

Live Preview

The same three lines keep counter-increment: section. Change only the parent counter-reset start value.

Each line still adds 1 with counter-increment, then prints counter(section).

Numbered lines

First

Second

Third

counter-reset: section

CSS Examples

Each snippet shows only what the counter needs: reset, increment, and content. Use Try It Yourself for a live editor.

Example 1 — Start at Zero

Create a counter with a bare name. The first increment prints 1.

CSS
<style>
  body {
    counter-reset: section;
  }

  h2 {
    counter-increment: section;
  }

  h2::before {
    content: counter(section) ". ";
  }
</style>

<h2>Intro</h2>
<h2>Setup</h2>
<h2>Next steps</h2>
Try It Yourself

How It Works

  1. Create the counter. counter-reset: section starts section at 0.
  2. Advance on each heading. counter-increment: section adds 1 on every h2.
  3. Print the value. content: counter(section) writes the number in ::before.
  4. Read the sequence. The headings become 1, 2, and 3.

Example 2 — Custom Start Value

Pass an integer to begin above zero. The first increment still adds 1.

CSS
<style>
  body {
    counter-reset: section 2;
  }

  h2 {
    counter-increment: section;
  }

  h2::before {
    content: counter(section) ". ";
  }
</style>

<h2>Part A</h2>
<h2>Part B</h2>
<h2>Part C</h2>
Try It Yourself

How It Works

  1. Set a custom start. section 2 creates the counter at 2.
  2. Increment as usual. Each h2 still adds 1.
  3. Print after the change. The values become 3, 4, and 5.
  4. Same idea for other starts. Use any integer, including negatives.

Example 3 — Nested Scopes Restart

Reset again on an inner parent so a new group starts over.

CSS
<style>
  .group {
    counter-reset: section;
  }

  h2 {
    counter-increment: section;
  }

  h2::before {
    content: counter(section) ". ";
  }
</style>

<div class="group">
  <h2>Alpha</h2>
  <h2>Beta</h2>
</div>
<div class="group">
  <h2>Gamma</h2>
  <h2>Delta</h2>
</div>
Try It Yourself

How It Works

  1. Reset per group. Each .group runs counter-reset: section.
  2. Share the increment rule. Every h2 still adds 1 to section.
  3. Scope stays local. The second group starts again at 0, so it prints 1, then 2.
  4. Use this for chapters. Restart numbering inside each section without new counter names.

Edge Cases & Pitfalls

If numbering looks wrong, check the reset scope first.

display

Reset alone shows nothing

You still need counter-increment and content with counter() to print numbers.

scope

Reset on every item restarts every time

Put counter-reset on a parent. Resetting on each child keeps the printed value stuck near the start.

names

Reset is not the same as set

counter-reset creates and initializes. counter-set assigns an absolute value later. Use the right one for the job.

limited

reversed() is not widely supported

For countdown everywhere, set a high start with counter-reset and use a negative counter-increment instead of reversed().

lists

list-item is a built-in counter

Ordered lists already use list-item. You can reset it (similar to start on <ol>), but custom names are clearer for learning.

Browser Support

counter-reset is a browser CSS property for creating counters. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

counter-reset

Basic named counters are supported in all modern browsers and Internet Explorer 8+. reversed() remains limited (mainly Firefox).

99% Counter support
Google Chrome 2+
Full support
Mozilla Firefox 1+
Full support
Apple Safari 3+
Full support
Microsoft Edge 12+
Full support
Opera 9.2+
Full support
Samsung Internet 1+
Full support
Internet Explorer 8+
Full support
counter-reset Widely supported

Bottom line: Safe for everyday numbering with counter-increment and content: counter(name). Avoid relying on reversed() for cross-browser work. It is not a runtime API.

Key Takeaways

  • Role: create named counters and set their starting integers.
  • Default start: a bare name begins at 0. The first increment usually prints 1.
  • Workflow: reset on a parent, increment on items, print with content: counter(name).
  • Initial value: none. Not inherited. Prefer a new reset to restart a nested group.

One line: counter-reset creates the counter — then increment and content make the numbers appear.

Frequently Asked Questions

It creates one or more named CSS counters and sets each to a starting integer. If you omit the integer, a regular counter starts at 0.
The initial value is none, which means no counters are created or reset on that element.
counter-reset creates and initializes a counter. counter-set jumps an existing counter to an absolute value. Despite the names, reset is usually the create step.
A bare name starts the counter at 0. The first counter-increment then adds 1, so the first printed value is usually 1.
Yes. List names with optional integers, separated by spaces, for example counter-reset: chapter section 2.
Basic counter-reset is Baseline and widely available in modern browsers and Internet Explorer 8+. The reversed() form has limited support (mainly Firefox). It is a browser CSS property, not a Node.js feature.

Next: counter-set

Learn how to jump an existing counter to an absolute value.

counter-set tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful