CSS counter-increment property
Example
A method for numbering sections and subsections (such as "Section 1", "1.1", "1.2"):
body
{
counter-reset:
section
;
}
h1
{
counter-reset:
subsection
;
}
h1
:before
{
counter-increment:
section
;
content:
"
Section
"
counter
(
section
) ". "
;
}
h2
:before
{
counter-increment:
subsection
;
content:
counter
(
section
) "."
counter
(
subsection
) " "
;
}
Try it »
Property definition and usage
The counter-increment property increments one or more counter values.
The counter-increment property is usually used with the counter-reset and content properties.
| Default value: | none |
|---|---|
| Inherited: | no |
| Version: | CSS2 |
| JavaScript syntax: | object.style.counterIncrement="subsection" |
Browser support





All major browsers support the counter-increment property.
**Note:** IE8 supports the counter-increment property only when a !DOCTYPE is specified.
Attribute values
| Value | Description |
|---|---|
| none | No counter will be incremented |
| id number | id defines the selector, id, or class whose count will be increased. number defines the increment. number can be positive, zero, or negative. |
| inherit | Specifies that the value of the counter-increment property should be inherited from the parent element |
Related Articles
CSS Reference Manual: :before pseudo-element
CSS Reference Manual: :after pseudo-element
CSS Reference Manual: The content attribute
CSS Reference Manual: counter-reset property