XML technologies / CSS / Advanced websites with CSS / CSS property reference / counter-reset
(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)
The property counter-reset resets a counter to a specific value each time the CSS rule is applied. By default, it resets the counter to 0, but any value may be specified.
Inherited: no
See also: counter-increment
Values
A counter name, optionally followed by a positive or negative integer specifying the value to which it should be reset. To reset several counters for a single element, specify their names and optional values separated by spaces. The default value none is also supported, but has no practical use.
Default value: none
Compatibility
CSS version: 2
Not supported by any current browser.
Example
The following rules use h1 elements and h2 elements to mark chapters and subchapters. Both elements are displayed with hierarchical numbering:
h1 {
counter-increment: chapter;
counter-reset: section;
}
h1:before {
content: "Kapitel " counter(chapter) " - ";
}
h2 {
counter-increment: section;
}
h2:before {
content: "Abschnitt " counter(chapter) "." counter(section) " - ";
}
Copyright © 2006 of the German translation, dpunkt.verlag GmbH
You may print the online version for your private use.
Otherwise, this chapter from “CSS − Anspruchsvolle Websites mit Cascading Stylesheets” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
dpunkt.verlag GmbH, Ringstraße 19, 69115 Heidelberg