Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Lists, Tables and Generated Content

The counter-increment property

Reference for the CSS counter-increment property: raise or lower a named counter each time an element appears, with live examples of nested numbering.

The counter-increment property adds a number to a named counter each time the element it is set on is rendered. Combined with counter-reset and content, it numbers headings, figures, table rows or anything else, with no markup changes.

CSS
figure { counter-increment: fig; }
figcaption::before { content: "Figure " counter(fig) ": "; }

Try it

Nested numbering like 1.1, 1.2, 2.1

Each h2 increments chapter and resets part, so the sub-numbers restart. The last heading adds 5 at once.

Syntax

CSS
counter-increment: 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 change. If no counter with that name is in scope, one is created first (starting at 0).
<integer> The amount to add; defaults to 1. Negative numbers count down, and 0 leaves the value unchanged.

Usage notes

  • It does not display anything. Print the value with counter() (or counters()) in content, usually on ::before.
  • Increment first, display after. An element's own increment happens before its ::before is generated, so the first heading shows 1 when the counter started at 0.
  • Missing reset. If you forget counter-reset, the counter is created automatically on the element that increments it, starting at 0, and its scope is that element, its descendants and its following siblings. Numbering outside that scope can then look wrong. Reset it explicitly.
  • display: none skips. Hidden elements do not count; use visibility: hidden to keep the numbering.
  • Multiple counters. counter-increment: a 2 b -1; changes two counters at once.
  • Same property, one declaration. A later counter-increment rule replaces the whole value, so list all counters together.

Browser support

Supported in all browsers.