NOTICE: This website is no longer updated or supported - as such many of the techniques used to build it may seem antiquated in the modern day. It is preserved for historical reasons only.

HTML XHTML The Complete Reference
home » reference » appendix b » css1 / css2 properties

counter-increment


This property accepts one or more names of counter names, each one optionally followed by an integer. The integer indicates by how much the counter is incremented or decremented for every occurrence of the element. The default increment is 1. Zero and negative integers are allowed. By default, counters are formatted as decimal numbers, but the styles supported by the list-style-type property are also available for counters and are specified with the syntax counter(name, list-style-type).

Examples


div.section:before {content: "Section: " counter(section) ". ";
counter-increment: section;} /* Add 1 to section */
h1.chapter:before {content: counter(chno, upper-latin) ". ";
counter-increment: chno; }
.topten:before {content: counter(countdown) ". ";
counter-increment: countdown -1; }

Browser and CSS Support Notes


CSS2
IE not yet supported
No Mozilla or Nav support yet
Opera 7


counter-reset


This property contains a list of one or more counter names, each one optionally followed by an integer. The integer gives the value that the counter is set to on each occurrence of the element. The default value is 0.

Examples


div.section:before {content: "Section: " counter(section) ". ";
counter-increment: section;} /* Add 1 to section */
div.chapter:before {counter-reset: section;} /* Set section to 0 */

Browser and CSS Support Notes


CSS2
IE not yet supported
Nav and Mozilla not yet supported
Opera 7

(X)HTML Elements
CSS Properties
Back: content Next: cursor
< Home | About | Chapters | Examples | Errata | Reference | Site Map >