CSS counter-increment
Property
Topic: CSS3 Properties ReferencePrev|Next
Description
The counter-increment
CSS property increments one or more counter values. This property is very useful for creating auto-numbering feature.
The following table summarizes the usages context and the version history of this property.
Default value: | none |
---|---|
Applies to: | All elements |
Inherited: | No |
Animatable: | No. See animatable properties. |
Version: | CSS 2, 3 |
Syntax
The syntax of the property is given with:
The example below shows the counter-increment
property in action.
Example
Try this code »body {
counter-reset: section;
}
h1 {
counter-reset: category;
}
h1:before {
counter-increment: section;
content: "Section " counter(section) ". ";
}
h2:before {
counter-increment: category;
content: counter(section) "." counter(category) " ";
}
Property Values
The following table describes the values of this property.
Value | Description |
---|---|
identifier | The name of the counter to increment. |
integer | The value to add to the counter. The default increment is 1. Zero or negative values are allowed. |
none |
No counters will be incremented. This is default value. |
initial |
Sets this property to its default value. |
inherit |
If specified, the associated element takes the computed value of its parent element direction property. |
Browser Compatibility
The counter-increment
property is supported in all major modern browsers.
Basic Support—
|
Further Reading
See tutorial on: CSS Pseudo Elements.
Related properties: content
, counter-reset
.