English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
counter-resetCSS property with counter-The combination of increment properties is used to create an automatically incrementing counter and to display the generated counter value with the content property.
The table below provides usage instructions and version history for this property, as well as the syntax for using this property in JavaScript scripts.
Default value: | none |
---|---|
Applicable to: | 所有元素 |
All elements | Inheritance: |
None | Can be animated:No. Please see. |
Animation Attributes | Version: 2CSS3 |
, | object.style.counterReset="section" |
The syntax of this attribute is as follows:
counter-reset: [ identifier integer ] 1 or more pairs | none | initial | inherit
The following examples demonstrate how to use counter-reset attribute.
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) " "; }Test to see‹/›
The following table describes the value of this attribute.
Value | Description |
---|---|
identifier | The name of the counter to be reset. |
integer | each time it appearsWhen selectingReset the value of the counter. The default reset value is 0. |
none | No counter will be reset. This is the default value. |
initial | Set this attribute to its default value. |
inherit | If specified, the associated element uses its parent element counter-The value of reset attribute. |
counter-Browser Compatibility of reset Attribute, the numbers in the following table represent the minimum version of the browser that supports this attribute; all mainstream browsers support this attribute.
|
Warning: Internet Explorer 7and earlier versions do not support this counter-increment Attribute. IE8Only in<!DOCTYPE>Supports only when a valid value is specified.
Please refer to the following tutorials:CSS Pseudo-elements.
Related Attributes:content,counter-increment.