CSS2 » Properties » counter-reset

Version: Level 2

Compability: Currently not supported by any browser.

Syntax:
counter-reset : none | identifier number
identifier
The identifier value part of the pair is mandatory and identifies the counter. It can refer to a class, id, or selector. The optional number value is the numeric value to reset to. It can be zero or any positive or negative integer. If omitted, the default is zero.
none
The none value prevents the counter from resetting.

The counter-reset property is a blank space delimited list of one or more identifier/number pairs associated with a selector. The pair sets the numeric value that the named counter will be reset to when the specified selector is encountered. The number part of the pair is optional and the default is zero. This property is not inherited.

For example, you could consecutively number nesting paragraphs, sub-sections of a text, and images in a chapter as 1.0, 1.1, 1.2, etc.
 
If the display property is set to none, then you cannot reset. If the visibility property is set to hidden, then you can reset.
 
You can use the content property to insert counters either before or after a specified element.

Examples

Code:
ol { counter-reset: item }
li { display: block }
li:before { content: counters(item, "."); counter-increment: item }
Explanation:

This code from W3C numbers paragraphs as 1, 1.1, 1.1.1, etc.

Language(s): CSS2

See Also: