Menu

Post image 1
Post image 2
1 / 2
0

CSS Counters: Automatic Numbering of Lists

DEV Community·Nick Benksim·26 days ago
#N2TzwcD9
#css#webdev#frontend#programming#counter#list
Reading 0:00
15s threshold

Stop Manually Numbering Your Lists Like It is 1999 Picture this: you are building a complex documentation page or a fancy "How-To" section. The designer wants big, bold numbers that overlap the text, have gradients, and maybe even a custom suffix like "Step 01". If you reach for a standard <ol> and <li> , you are going to hit a wall fast. The default styling for list markers is notoriously stubborn and limited. You can change the type to "decimal" or "roman," but making them truly "pop" usually leads to a world of pain. That is exactly where CSS counters come in—a way to turn any element into a smart, auto-incrementing machine without touching a single line of JavaScript. How we suffered before Back in the day, if we needed custom-styled numbers, we usually resorted to some pretty ugly hacks. The most common "solution" was hardcoding the numbers directly into the HTML: <span class="number">1.</span> . It worked until the client decided to add a new step in the middle of the list.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More