counter-reset property
8 | ||||
Sets the list of counters and their initial values.
The value of this property is a space-delimited list of identifier-value pairs, where identifier is the name of a counter, and value is the initial value.
The value is optional, its default value is 0.
You can define more than one identifier-value pair; in that case all counters specified with the identifiers will be defined/reset at every occurrence of the element.
This property is useful if you want to generate the numbering with names like the header numbering mechanism in Microsoft Word. Use it together with the content and the counter-increment properties to create automatic numbering.
This property is useful if you want to generate the numbering with names like the header numbering mechanism in Microsoft Word. Use it together with the content and the counter-increment properties to create automatic numbering.
Note: The counter-reset property is supported in Internet Explorer from version 8.
JavaScript page for this property: counterReset. You can find other example(s) there. |
Possible values:
One of the following values: | ||||||||||||||||||
|
Description of values:
String, the name of the counter. | |||||||
Takes the value of this property from the computed style of the parent element. | |||||||
Integer,the initial value of the counter. The default value is 0. | |||||||
Use automatic numbering. |
Default: none.
Example HTML code 1:
This example illustrates the use of the counter-reset property:
|
||||
<head> <style> body { counter-reset: chapter; /* set chapter counter to 0*/ } .chapter:before { content: counter(chapter) ". "; display: inline; } .chapter { counter-increment: chapter; /* increment chapter counter by 1, same as counter-increment: chapter 1;*/ counter-reset: section; /* set section counter to 0*/ font-size: 20px; font-weight: bold; } .section:before { content: counter(chapter) "." counter(section) "."; display: inline; } .section { counter-increment: section; /* increment section counter by 1, same as counter-increment: section 1;*/ font-size: 15px; font-weight: bold; padding-left: 10px; } </style> </head> <body> <div class="chapter">First chapter</div> <div class="section">First section in Chapter 1</div> <div class="section">Second section in Chapter 1</div> <div class="section">Third section in Chapter 1</div> <div class="section">Fourth section in Chapter 1</div> <div class="chapter">Second chapter</div> <div class="section">First section in Chapter 2</div> <div class="section">Second section in Chapter 2</div> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by tags:
a, abbr, acronym, address, b, bdo, big, blink, blockQuote, body, button, caption, center, cite, code, col, colGroup, dd, del, dfn, dir, div, dl, dt, em, fieldSet, font, form, H1, H2, H3, H4, H5, H6, html, i, ins, isIndex, kbd, label, legend, li, listing, marquee, menu, nobr, noFrames, noScript, ol, p, plainText, pre, q, rt, ruby, s, samp, small, span, strike, strong, sub, sup, table, td, textArea, th, tr, tt, u, ul, var, xmp
Related pages:
External links:
counter-reset (MSDN)
counter-reset (Mozilla Developer Center)
counter-reset (Safari Reference Library)
counter-reset (W3C)
counter-reset (Mozilla Developer Center)
counter-reset (Safari Reference Library)
counter-reset (W3C)
User Contributed Comments