CSS counter-reset Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Counters

What You’ll Learn

The counter-reset property creates or resets CSS counters — the starting point before counter-increment and content: counter().

01

Initialize

Create counters.

02

Reset

Start over.

03

Default none

No counter set.

04

Start Value

Optional number.

05

With increment

Full counter flow.

06

Nested

Scoped numbering.

Definition and Usage

The counter-reset CSS property creates or resets one or more CSS counters. Counters track the occurrence of elements and are often used for numbering items in a list, creating custom section counters, or managing complex numbering schemes in documents.

Place counter-reset on a container (such as body, an article, or a list) before using counter-increment on child elements and displaying values with content: counter(name).

💡
Beginner Tip

counter-reset: section; sets the counter to 0. After the first counter-increment: section;, the displayed value is 1. Use a custom start like counter-reset: section 4; to begin at 5 after increment.

📝 Syntax

The syntax lets you specify one or more counters and their initial values:

syntax.css
selector {
  counter-reset: name number;
}

Basic Example

counter-reset-section.css
body {
  counter-reset: section;
}

h2::before {
  counter-increment: section;
  content: "Section " counter(section) ": ";
}
counter-reset: section; counter-reset: item 0; counter-reset: chapter 1; counter-reset: none;

Syntax Rules

  • The initial value is none — no counter is created or reset.
  • Omitting the number defaults the start value to 0.
  • Reset multiple counters: counter-reset: chapter section;.
  • Nested elements can reset counters to scope numbering locally.
  • Always pair with counter-increment and counter() for visible numbering.

⚡ Quick Reference

QuestionAnswer
Initial valuenone
Applies toAll elements
InheritedNo
AnimatableNo
Default start when number omitted0

💎 Property Values

The counter-reset property accepts counter names, optional start numbers, and none.

ValueDescription
noneNo counter is created or reset.
nameThe name of the counter to reset.
numberThe initial value for the counter (optional). If omitted, the initial value is 0.

The CSS Counter System

Property / FunctionRole
counter-resetCreates or resets a counter (this property)
counter-incrementIncreases the counter on matching elements
counter(name)Displays the current counter value in content
counter-setSets a counter to a specific value without incrementing

👀 Live Preview

The container uses counter-reset: section; each heading increments and displays “Section 1:”, “Section 2:”, etc.

Introduction

This is the introduction section.

Background

This is the background section.

Conclusion

This is the conclusion section.

Examples Gallery

Try document section numbering, custom start values, scoped list resets, and multiple counters.

🔢 Basic Counter Reset

Start with the reference example — reset a section counter on the body for numbered headings.

Example 1 — Number Document Sections

Create a counter to number the sections of a document.

counter-reset-section.html
<style>
  body {
    counter-reset: section;
  }
  h2::before {
    counter-increment: section;
    content: "Section " counter(section) ": ";
  }
</style>

<h2>Introduction</h2>
<h2>Background</h2>
<h2>Conclusion</h2>
Try It Yourself

How It Works

counter-reset: section on body initializes the counter to 0 before any headings increment and display it.

Example 2 — Custom Starting Value

Start numbering from 5 by resetting the counter to 4 before increments.

counter-reset-start.css
.numbered {
  counter-reset: item 4;
}

.numbered li {
  counter-increment: item;
}

.numbered li::before {
  content: counter(item) ". ";
  font-weight: bold;
}
Try It Yourself

How It Works

counter-reset: item 4 sets the counter to 4; the first increment displays 5.

🛠 Scoped & Multiple Resets

Reset counters on nested containers or initialize several counters together.

Example 3 — Scoped Reset on Each Article

Reset the counter on each article so numbering restarts per block.

counter-reset-scoped.css
article {
  counter-reset: step;
}

article h3 {
  counter-increment: step;
}

article h3::before {
  content: "Step " counter(step) ": ";
  color: #2563eb;
  font-weight: 600;
}
Try It Yourself

How It Works

Each article resets its own step counter, so numbering starts at 1 again in every article.

Example 4 — Reset Multiple Counters

Initialize chapter and section counters together for nested outline numbering.

counter-reset-multiple.css
.outline {
  counter-reset: chapter section;
}

.outline h2 {
  counter-increment: chapter;
  counter-reset: section;
}

.outline h2::before {
  content: "Chapter " counter(chapter) ": ";
}
Try It Yourself

How It Works

counter-reset: chapter section; initializes both counters; each h2 increments chapter and resets section for sub-numbering.

🧠 How counter-reset Works

1

You set counter-reset

Initialize a named counter on a container: counter-reset: section;.

CSS rule
2

counter-increment advances

Child elements increase the counter when encountered.

Increment
3

counter() displays value

Show the number in a pseudo-element with content: counter(section).

Display
=

Controlled numbering

Counters start at a predictable value and produce automatic numbers.

Modern Browser Support

The counter-reset property is supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera.

Baseline · Modern browsers

Counter reset everywhere

All major browsers support counter-reset as a well-established CSS feature.

99% Modern browser support
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions
Full support
Opera All modern versions
Full support
counter-reset property 99% supported

Bottom line: Use counter-reset confidently in modern projects. Pair it with increment and content for full counter workflows.

Conclusion

The counter-reset property is a versatile tool for managing counters in your web documents. Whether you’re creating numbered lists, custom section counters, or complex numbering schemes, this property provides a straightforward way to initialize and manage counters.

Experiment with different counter names and values to see how they can enhance the structure and readability of your content.

💡 Best Practices

✅ Do

  • Reset counters on the container before incrementing children
  • Use scoped resets on articles or sections for independent numbering
  • Choose descriptive counter names like chapter or step
  • Set custom start values when numbering should not begin at 1
  • Combine with counter-increment and content: counter()

❌ Don’t

  • Forget to reset — counters may inherit unexpected values
  • Rely on CSS counters for critical accessibility structure
  • Reset and increment on the same element without understanding order
  • Use confusing counter names across unrelated components
  • Expect visible numbers without content: counter()

Key Takeaways

Knowledge Unlocked

Five things to remember about counter-reset

Use these points when initializing CSS counters.

5
Core concepts
02

Default none

No reset.

Default
🖌 03

Start at 0

If no number.

Syntax
📝 04

First step

Before increment.

Tip
🛸 05

Scoped

Per container.

Pattern

❓ Frequently Asked Questions

counter-reset creates or resets one or more CSS counters to a specified initial value. It is the first step in building automatic numbering with CSS counters.
The initial value is none, which means no counter is created or reset.
counter-reset initializes or resets a counter to a starting value. counter-increment increases the counter each time a matching element is encountered.
If you write counter-reset: section without a number, the counter starts at 0. The first counter-increment typically displays 1.
Yes. You can list several counters: counter-reset: chapter section; or set custom starts: counter-reset: item 0 chapter 1;

Practice in the Live Editor

Open the HTML editor, set counter-reset: section on a container, and build automatic section numbering.

HTML Editor →

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.

5 people found this page helpful