CSS counter-increment Property

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The counter-increment property increases or decreases one or more named CSS counters. If you write only a counter name, that counter goes up by 1. A negative integer counts down.

Show the value with content and counter() on ::before or ::after. Use counter-reset for a clear starting value. The initial value is none. It is not inherited.

Baseline · Widely available.

Not deprecated and not experimental. Pair it with counter-reset and content: counter(name) for automatic numbering.

CSS Syntax

syntax.css
counter-increment: [ <counter-name> <integer>? ]+ | none | initial | inherit;

List one or more counter names, each optionally followed by an integer. Omit the integer to add 1.

Property Values

ValueDescriptionTry it
<counter-name>The counter to change. Alone, it increases by 1Try it
name + integerAdd that integer each time, such as section 2Try it
Negative integerSubtracts from the counter, such as section -1Try it
0 on a nameKeeps that counter unchanged. Other counters can still moveTry it
noneDo not change any counters. Initial value. Cancels increments from other rulesTry it
initialSets this property to its default value, noneTry it
inheritInherits this property from the parent elementTry it

How to Use counter-increment

Reset a counter, increment it on each item, then print it with content.

  1. On a parent, set counter-reset: section (or another name).
  2. On each child that should advance the count, set counter-increment: section.
  3. On ::before (or ::after), set content: counter(section).
  4. Change the integer when you need steps of 2, -1, or a freeze with 0.
PieceRequired?Role
counter-resetRecommendedCreates a predictable starting value
counter-incrementYesMoves the counter on each matching element
content: counter(...)To display itWrites the current value into generated content
IntegerOptionalDefaults to 1. Use negatives to count down

Live Preview

The same four lines share one counter. Change how much counter-increment adds each time.

Parent uses counter-reset: section. Each line prints counter(section) before its text.

Numbered lines

First

Second

Third

Fourth

counter-increment: section

CSS Examples

Each snippet shows only what the counter needs: reset, increment, and content. Use Try It Yourself for a live editor.

Example 1 — Count by One

Increment a named counter on each heading and print it.

CSS
<style>
  body {
    counter-reset: section;
  }

  h2 {
    counter-increment: section;
  }

  h2::before {
    content: counter(section) ". ";
  }
</style>

<h2>Intro</h2>
<h2>Setup</h2>
<h2>Next steps</h2>
Try It Yourself

How It Works

  1. Create the counter. counter-reset: section starts section at 0.
  2. Advance on each heading. counter-increment: section adds 1 every time an h2 is styled.
  3. Print the value. content: counter(section) writes the current number in ::before.
  4. Read the sequence. The three headings become 1, 2, and 3.

Example 2 — Count by Two

Pass an integer to jump by more than one.

CSS
<style>
  body {
    counter-reset: section;
  }

  h2 {
    counter-increment: section 2;
  }

  h2::before {
    content: counter(section) ". ";
  }
</style>

<h2>Even A</h2>
<h2>Even B</h2>
<h2>Even C</h2>
Try It Yourself

How It Works

  1. Reset as usual. The counter still starts at 0.
  2. Add two each time. section 2 means every matching element adds 2.
  3. Display the result. The printed values become 2, 4, and 6.
  4. Same pattern for other steps. Any integer works the same way.

Example 3 — Count Down

Start higher with counter-reset, then subtract with a negative increment.

CSS
<style>
  body {
    counter-reset: section 4;
  }

  h2 {
    counter-increment: section -1;
  }

  h2::before {
    content: counter(section) ". ";
  }
</style>

<h2>Three</h2>
<h2>Two</h2>
<h2>One</h2>
Try It Yourself

How It Works

  1. Set a high start. counter-reset: section 4 begins at 4.
  2. Subtract on each item. section -1 decreases the counter by one.
  3. Print after the change. The first heading shows 3, then 2, then 1.
  4. Freeze vs cancel. Use section 0 to skip one item, or none to block every counter on that rule.

Edge Cases & Pitfalls

If the numbers look wrong, one of these is usually why.

display

Increment alone shows nothing

Counters are invisible until you print them with content and counter() on a pseudo-element.

none

none cancels every counter

To freeze only one name, use counter-increment: section 0. none blocks all increments on that element.

order

Reset and increment are different jobs

counter-reset sets the starting value. counter-increment changes it later. Putting reset on every item restarts the count.

scope

Missing reset still creates a counter

Increment can create a counter automatically, often starting near 0. Prefer an explicit counter-reset so the first printed value is predictable.

set

counter-set is not an increment

counter-set jumps to an absolute value. Use increment when each match should add or subtract a step.

Browser Support

counter-increment is a browser CSS property for automatic numbering. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

counter-increment

Supported in all modern browsers and Internet Explorer 8+. CSS counters have been available across browsers for a long time.

99% Counter support
Google Chrome 2+
Full support
Mozilla Firefox 1+
Full support
Apple Safari 3+
Full support
Microsoft Edge 12+
Full support
Opera 9.2+
Full support
Samsung Internet 1+
Full support
Internet Explorer 8+
Full support
counter-increment Widely supported

Bottom line: Safe for everyday numbering with counter-reset and content: counter(name). It is not a runtime API.

Key Takeaways

  • Role: add or subtract from named CSS counters on matching elements.
  • Default step: a bare name increases by 1. Use an integer for other steps.
  • Display: print with content: counter(name) on ::before or ::after.
  • Initial value: none. Not inherited. Prefer 0 to freeze one counter.

One line: counter-increment moves the counter — reset first, increment on each item, then print with content.

Frequently Asked Questions

It increases or decreases one or more named CSS counters by the given integers. If you omit the integer, the counter increases by 1.
The initial value is none, which means no counters are changed on that element.
Use content with the counter() function on ::before or ::after, for example content: counter(section). Pair that with counter-reset for a clear starting value.
Use none only when you want to cancel every increment. To freeze one named counter, set its integer to 0, such as counter-increment: section 0.
Yes. If the named counter does not exist yet, CSS creates it. Still prefer counter-reset when you need a predictable start value.
It is Baseline and widely available in all modern browsers and Internet Explorer 8+. It is a browser CSS property, not a Node.js feature.

Next: counter-reset

Learn how to create a counter and set its starting value.

counter-reset tutorial →

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.

8 people found this page helpful