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.
- PHP Interview Questions and Answers | Set-2
- How to Create a Tab Image Gallery ?
- XML full form
- How to create an Affix or sticky Navbar ?
- JSON full form
- HTML full form
- CSS | fit-content() Property
- How to change the placeholder text using jQuery?
- How to perform wordpress security auditing?
- Laravel | Route::resource vs Route::controller
- Python - Call function from another function
- Python - Initialize empty array of given length
- Ruby Static Members
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.
Improved By : Akanksha_Rai