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.
Fundamentals
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.
Foundation
📝 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.
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.
Compatibility
🖥 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 Chrome68+ · Desktop & Mobile
Full support
Mozilla Firefox68+ · Desktop & Mobile
Full support
Apple Safari13.1+ · macOS & iOS
Full support
Microsoft Edge79+ (Chromium)
Full support
Opera55+
Full support
counter-set property96% supported
Bottom line: Use counter-set in modern projects. For very old browsers, fall back to counter-reset scoped containers.
Wrap Up
🎉 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.
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
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about counter-set
Use these points when assigning CSS counter values.
5
Core concepts
🔢01
Set value
Assign directly.
Purpose
⚙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.