Counters in CSS are basically variables which can be used for numbering and values of CSS counters may be incremented by CSS rules. For example, CSS counters can be used to increment the numbering of the headings automatically. In HTML, <ol> tag is used to give the ordered numbers to list items but CSS contains counter to give order elements in some other fashion.
CSS counters properties: CSS counters contains the following properties:
- counter-reset: It is used to reset a counter.
- counter-increment: It basically increments a counter value.
- content: It is used to generate content.
- counter() or counters() function: The value of a counter can be displayed using either the counter() or counters() function in a content property. These two functions basically used to add the value of a counter to the element.
Initialization the CSS Counter: To use CSS counter property firstly it must be created with the counter-reset property and the first step is resetting the counter. The myCounter by default initialized to a value 0(zero) with the counter-reset property.
Incrementation and Use of CSS Counter: To incrementing the counter use CSS counter-increment property.
The counter() or counters() function in a content is used to display the content in a particular order.
Nested CSS counters: The counter within a counter is known as nested counter. Nested counter are used to create heading and subheadings. This example shows the use of CSS counters with nested tags. Different counter are used for different type of tags.
- Formatting integer column of Dataframe in Pandas
- Screen Reader utilities in bootstrap with Examples
- Input Groups in Bootstrap with Examples
- ifconfig command in Linux with Examples
- HTML | DOM Style letterSpacing Property
- HTML | DOM Style minHeight Property
- HTML | DOM Style counterReset Property
- HTML | DOM Style borderWidth Property
- HTML | DOM Style justifyContent Property
- ConcurrentLinkedDeque size() method in Java
- HTML | DOM Samp Object
- HTML | DOM OptionGroup Object
- HTML | DOM execCommand() Method
- CSS | page-break-inside Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.