Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Lists, Tables and Generated Content

The counter-set property

Reference for the CSS counter-set property: assign a specific value to an existing counter without creating a new scope, unlike counter-reset.

The counter-set property assigns a value to a counter. It is like counter-reset, with one important difference: it changes the current counter instead of creating a new nested one. If no counter with that name is in scope, it creates one.

Use it when you want to jump numbering to a specific value, for example to continue numbering after an interruption.

CSS
h2.appendix { counter-set: chapter 100; }

Try it

Jumping the numbering

The second <ul> sets the shared counter to 41. Each <li> then increments it by one before printing, so the numbers continue at 42.

Syntax

CSS
counter-set: none | [ <counter-name> <integer>? ]+;
Initial value none
Applies to All elements
Inherited No
Animatable No
Computed value none, or a list of name and integer pairs

Values

Value Description
none No counter is changed.
<counter-name> The counter to set.
<integer> The new value. Defaults to 0 if omitted.

Usage notes

  • Where you put it matters. The browser processes a fixed order of reset, increment and set on a single element. To avoid depending on that, set the value on a parent or on a different element than the one that increments, as the example does. Print the counter to check the result.
  • Versus counter-reset. counter-reset starts a new instance for the element's subtree. counter-set modifies the counter already in scope, so numbering elsewhere continues from the new value.
  • Typical uses: restarting numbering midway, skipping a range, or starting a list at a specific number without changing the HTML.
  • HTML alternatives. For real ordered lists, the start and value attributes do the same job and are visible in the markup.
  • Does not display anything. Print values with counter() in content.

Browser support

Supported in current browsers. It is newer than counter-reset and counter-increment, so check a compatibility table if you support older browsers.