English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS reference manual

CSS @rules

CSS attribute大全

CSS counter-Usage method and examples of reset property

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 elementsInheritance:
NoneCan be animated:No. Please see.
Animation AttributesVersion: 2CSS3
,object.style.counterReset="section"

counter-The syntax of reset usage

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‹/›

Attribute Value

The following table describes the value of this attribute.

ValueDescription
identifierThe name of the counter to be reset.
integereach time it appearsWhen selectingReset the value of the counter. The default reset value is 0.
noneNo counter will be reset. This is the default value.
initialSet this attribute to its default value.
inheritIf specified, the associated element uses its parent element counter-The value of reset attribute.

Browser Compatibility

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.

  • Firefox 1.5Above

  • Google Chrome2+

  • Internet Explorer 8+

  • Apple Safari 3+

  • Opera 9.2+

Warning: Internet Explorer 7and earlier versions do not support this counter-increment Attribute. IE8Only in<!DOCTYPE>Supports only when a valid value is specified.

Further Reading

Please refer to the following tutorials:CSS Pseudo-elements.

Related Attributes:content,counter-increment.