# counter-set

> The `counter-set` CSS property sets a counter to a specific value.

## How do I set a CSS counter to a specific number?

The property that directly sets the value of a counter to a specific number, overriding any previous value. This provides precise control over the counter's value, useful for custom numbering or complex layouts.

- Topic: Counters
- Type: property
- Browser support: Chrome 85+, Chrome Android 85+, Edge 85+, Firefox 68+, Firefox Android 68+, Safari 17.2+, Safari iOS 17.2+

## Example

Wrong:

```css
li {
  counter-increment: item;
}
li.jump {
  counter-reset: item 10;
}
```

Right:

```css
li {
  counter-increment: item;
}
li.jump {
  counter-set: item 10;
}
```

`counter-set` runs after the increment and reuses the existing counter, so this item shows 10 instead of 11.

## Common mistakes

- Using `counter-reset` on a middle item, which creates a new counter and shows one more than expected.

## Key points

- Jumps in numbering use `counter-set`, while `counter-reset` stays on the container that starts the counter.
- The set value is the number to show, since `counter-set` applies after `counter-increment`.

## Interview questions

### What is the difference between counter-set and counter-reset?

`counter-reset` creates a new counter scope. `counter-set` only changes the value of a counter that already exists.

### Can I set an ordered list item number without CSS?

Yes. The `value` attribute on `<li>` sets the number of that item in an `<ol>`.

## Related cards

- [counter-reset](https://wonderium.dev/css/counter-reset.md)
- [counter-increment](https://wonderium.dev/css/counter-increment.md)
- [counter()](https://wonderium.dev/css/counter.md)
- [`<li>`](https://wonderium.dev/html/li.md)
- [Counters](https://wonderium.dev/css/counters-concept.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/counter-set
- Last updated: 2026-11-25
