CSS Counters26 Mar 2025 | 2 min read CSS counters are similar to variables. These are maintained by CSS and those values can be incremented by CSS rules to track how many times they are used. CSS counters facilitate simple CSS based incrementing and display of a number for generated content. CSS Counter PropertiesFollowing is a list of properties that are used with CSS counter:
Note: Before using a CSS counter, it must be created with counter-reset.CSS Counter ExampleLet's take an example to create a counter for a page and increment the counter value for each next element. See this example: Test it NowNote: In the above example you can see that a counter is created for the page in the body selector and it increments the counter value for each <h2> element and adds "Section <value of the counter>:" to the beginning of each <h2> element.CSS Nesting CountersYou can also create counters within the counter. It is called nesting of a counter. Let's take an example to demonstrate nesting counter. See this example: Note: In the above example you can see that a counter is created for the section and another nesting counter named subsection is created within section.Different level of nesting countersYou can create outlined lists by using nesting counters. It facilitates you to insert a string between different levels of nested counters. See this example: Next TopicCSS clearfix |
Background-Size in CSS Introduction We can determine the size of the background image with the help of the property. We can make the image as left, stretched, and fit for the available space. There are so many syntaxes for the implementation of the property. We...
8 min read
In the CSS pseudo-element, the placeholder selector is used to customize the placeholder text by altering the text color and style. The ::first-line pseudo-element is the only relevant CSS property subset that may be used in a rule with the selector ::placeholder. The placeholder text is a...
3 min read
The appearance of components on a webpage can be softened by using CSS to create rounded borders. Rounded borders offer a feeling of aesthetics and might enhance the visual attractiveness of the entire design. I'll go over all the different attributes and values you may use...
17 min read
The CSS float property is a positioning property. It is used to push an element to the left or right, allowing other element to wrap around it. It is generally used with images and layouts. To understand its purpose and origin, let's take a look to...
2 min read
The color property in CSS is used to set the color of HTML elements. Typically, this property is used to set the background color or the font color of an element. In CSS, we use color values for specifying the color. We can also use this...
5 min read
CSS Border-collapse Property Cascading Style Sheets (CSS) play a pivotal role in designing and styling web pages, offering a myriad of properties to control the layout and appearance of elements. One such property that holds significance in table formatting and design is border collapse. This property allows...
6 min read
Width Property in CSS The width belongings in CSS is used to specify an element's width. It indicates the element's content location width, omitting margins, borders, and padding. Units of dimension for the width property include pixels (px), probabilities (%), em devices, and different period devices. Here's...
4 min read
CSS Transform Origin This CSS property is used to change the position of transformed elements. It is a point around which the transformation is applied. It establishes the origin of the transformation of an element. It can be applied to both 2D and 3D rotations. The transform-origin...
21 min read
What is the Last Child in CSS? In CSS, the last element within its parent element is chosen using the last child pseudo-class. The last child of its parent within the document tree structure is the object of this pseudo-class. It is frequently used to apply particular...
7 min read
CSS: Cascading Style Sheets CSS is a stylesheet language used to specify the display of an HTML or XML document (including XML dialects such as SVG, MathML, or XHTML). CSS specifies how items should be shown on screen, paper, during the speech, or in other mediums. CSS is...
4 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India