CSS counter-set Property

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

What You’ll Learn

The counter-set property assigns a CSS counter to a specific value — the fine-grained control between counter-reset and counter-increment.

01

Set Value

Assign a number.

02

Mid-document

Change on the fly.

03

Default none

No change.

04

Jump / restart

Skip or resume.

05

With increment

Full counter flow.

06

Multiple

Sync counters.

Introduction

The counter-set property in CSS is used to initialize or reset a counter to a specific value. Counters in CSS are useful for numbering elements, such as lists, sections, and other content that requires ordered numbering.

This property allows you to control the starting point or change the count within a document without necessarily creating a new nested counter scope the way counter-reset does.

Definition and Usage

Apply counter-set on an element when an existing counter should jump to a known value. Pair it with counter-reset (to create the counter), counter-increment (to advance numbering), and content: counter(name) (to display the value).

💡
Beginner Tip

counter-set sets the value before the next counter-increment. To display “Section 1” after a restart, use counter-set: section 0; so the increment shows 1.

📝 Syntax

The syntax for the counter-set property is straightforward. It takes one or more counter names and optional integer values.

syntax.css
element {
  counter-set: counter-name value;
}

Here, counter-name is the name of the counter to be set, and value is an optional integer that specifies the new value for the counter. If value is not specified, the counter is set to 0.

Basic Example

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

h2::before {
  counter-increment: section;
  content: "Section " counter(section) ": ";
}

.reset-counter {
  counter-set: section 0;
}
counter-set: section 0; counter-set: item 10; counter-set: chapter 2 section 3; counter-set: none;

Default Value

The default (initial) value of the counter-set property is none, meaning no counter value is changed.

Syntax Rules

  • The initial value is none — no counter is set.
  • Omitting the number sets the counter to 0.
  • Set multiple counters: counter-set: chapter 2 section 3;.
  • The counter must already exist (usually via counter-reset or prior increment).
  • Remember that counter-increment runs after the set value on the same element.

⚡ Quick Reference

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

💎 Property Values

The counter-set property accepts counter names, optional integer values, and none.

ValueDescription
noneNo counter value is changed.
counter-nameThe name of the counter you want to set or reset.
valueAn optional integer value to set the counter to. If omitted, the counter is set to 0.

The CSS Counter System

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

👀 Live Preview

Section headings increment normally until counter-set: section 0 restarts the sequence.

Introduction

This is the introduction section.

Details

This is the details section.

counter-set: section 0 — numbering restarts below

Reset Section

Displays as Section 1 after the set value.

Conclusion

This is the conclusion section.

Examples Gallery

In these examples, we use counter-set to initialize or change counters for sections, steps, figures, and outline numbering.

🔢 Basic Counter Set

Start with the reference pattern — restart section numbering mid-document.

Example 1 — Restart Section Numbering

Use counter-set on a wrapper to change the section counter and restart heading numbers.

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

<h2>Introduction</h2>
<h2>Details</h2>
<div class="reset-counter">
  <h2>Reset Section</h2>
</div>
<h2>Conclusion</h2>
Try It Yourself

How It Works

counter-set: section 0 on the wrapper sets the counter to 0; the next h2 increments and displays Section 1 again.

Example 2 — Jump to a Specific Number

Skip optional steps by setting the counter to 10 before the next list item increments.

counter-set-jump.css
.steps li.jump {
  counter-set: step 10;
  counter-increment: none;
}
Try It Yourself

How It Works

The jump item sets the counter to 10 without incrementing; the next item increments to 11.

🛠 Resume & Sync Counters

Handle editorial breaks and align multiple counters for complex outlines.

Example 3 — Resume After a Note Block

Set the figure counter so numbering continues correctly after an unnumbered note.

counter-set-resume.css
.note {
  counter-set: figure 2;
}
Try It Yourself

How It Works

After two figures, counter-set: figure 2 keeps the sequence logical so the next figure displays as Figure 3.

Example 4 — Set Multiple Counters

Sync chapter and section counters to jump an appendix to a specific outline position.

counter-set-multiple.css
.appendix {
  counter-set: chapter 3 section 2;
}
Try It Yourself

How It Works

counter-set: chapter 3 section 2 positions both counters; increments produce Chapter 4 and sections 4.3, 4.4.

🧠 How counter-set Works

1

Counter already exists

Create it with counter-reset or prior increments.

Prerequisite
2

You apply counter-set

Assign a new value: counter-set: section 0;.

Set value
3

counter-increment continues

The next matching element increments from the set value.

Increment
=

Flexible numbering

Jump, restart, or sync counters anywhere in the document tree.

🖥 Browser Compatibility

The counter-set property is supported in most modern browsers, including recent versions of Chrome, Firefox, Safari, Edge, and Opera. Test across browsers for production layouts.

Baseline · Modern browsers

Counter set in modern engines

All major browsers added counter-set support in 2019–2020. Use it confidently alongside other CSS counter properties.

96% Modern browser support
Google Chrome 68+ · Desktop & Mobile
Full support
Mozilla Firefox 68+ · Desktop & Mobile
Full support
Apple Safari 13.1+ · macOS & iOS
Full support
Microsoft Edge 79+ (Chromium)
Full support
Opera 55+
Full support
counter-set property 96% supported

Bottom line: Use counter-set in modern projects. For very old browsers, fall back to counter-reset scoped containers.

🎉 Conclusion

The counter-set property is a powerful tool for managing and displaying ordered content on your web pages. By initializing or resetting counters to specific values, you can create complex numbering schemes that enhance the structure and readability of your documents.

Experiment with different counter values and see how this property can be used to improve your web projects.

💡 Best Practices

✅ Do

  • Create counters with counter-reset before using counter-set
  • Account for the next counter-increment when choosing set values
  • Use counter-increment: none on jump markers that should not advance
  • Sync multiple counters together when building outline-style numbering
  • Test numbering output in the live editor before shipping

❌ Don’t

  • Confuse counter-set with counter-reset — they behave differently
  • Expect visible numbers without content: counter()
  • Rely on CSS counters alone for accessibility-critical structure
  • Set values without understanding increment order on the same element
  • Assume legacy browsers support counter-set

Key Takeaways

Knowledge Unlocked

Five things to remember about counter-set

Use these points when assigning CSS counter values.

5
Core concepts
02

Default none

No change.

Default
🖌 03

Omit = 0

If no number.

Syntax
📝 04

Before increment

Plan display.

Tip
🛸 05

Mid-document

Jump or restart.

Pattern

❓ Frequently Asked Questions

counter-set assigns a named CSS counter to a specific integer value. Use it to change numbering mid-document without creating a new nested counter scope like counter-reset does.
The initial value is none, which means no counter value is changed.
counter-reset creates or resets counters and establishes nested counter scopes. counter-set only changes the value of an existing counter at that point in the tree — useful for jumps or restarts without a full reset scope.
If you write counter-set: section without a number, the counter is set to 0. The next counter-increment typically displays 1.
Use counter-increment to advance numbering normally. Use counter-set when you need to jump to a specific value, restart a sequence, or sync multiple counters to known positions.

Practice in the Live Editor

Open the HTML editor, set counter-set: section 0 on a wrapper, and restart 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