counter-increment property
Sets or retrieves a list of counters to increment.
![]() ![]() |
Syntax
counter-increment: [
<identifier>
<integer>
]+
Property values
A variable of type String that specifies or receives a space-delimited list of counters, including one or both of the following values.
- identifier
-
The name of the counter, optionally followed by an increment.
- integer
-
An integer that indicates by how much the counter is incremented for every occurrence of the element. Zero and negative integers are allowed.
CSS information
| Applies To | All elements |
|---|---|
| Media | visual |
| Inherited | no |
| Initial Value |
Standards information
- CSS 2.1, Section 12.4
Remarks
The counter-increment attribute can contain a list of one or more counters, each one optionally followed by an integer. The integer represents the amount that the counter is incremented after each occurrence of an element.
This property is used to generate numbered content for each occurrence of an element. The counter need not be defined before it is incremented. To reset a counter value, use the counter-reset attribute.
An element that is not displayed (display attribute set to 'none') and pseudo-elements that do not generate content (content attribute set to 'normal') cannot increment or reset a counter.
This property requires Windows Internet Explorer to be in IE8 Standards mode rendering.
Examples
The following example demonstrates automatic
chapter and section numbering using
counter-reset,
counter-increment,
and content.
The chapter counter is set to zero for the
body element,
and then incremented for each hn
element encountered. The section counter is
reset for each hn element and
incremented for each hn element.
When the page is viewed, each
hn element is preceded by
a chapter heading of the form
"ChapterX.",
while each hn element is preceded by
a section number of the form
"X.N".
<meta http-equiv="X-UA-Compatible" content="IE=8" /> <style type="text/css"> body { counter-reset: chapter; /* Create a chapter counter */ } h1 { counter-increment: chapter; /* Add 1 to chapter */ counter-reset: section; /* Set section to 0 */ } h1:before { content: "Chapter " counter(chapter) ". "; } h2 { counter-increment: section; } h2:before { content: counter(chapter) "." counter(section) " "; } </style>
See also

