freecoding.school100% FREE · NO SIGNUP
Neon DistrictISSUE #30 of 50

counters · counter-reset · counter-increment

PrismaVSJank the Janitor
Prisma saysCSS counters number things automatically with counter-reset and counter-increment.

CSS can count without JavaScript. counter-reset: step starts a counter, counter-increment: step bumps it per element, and content: counter(step) in a ::before prints it. Perfect for custom-styled ordered lists, numbered headings, or step indicators.

Power-ups you unlock

Jank the Janitor attacks — common mistakes

Boss battleNumber a custom list with CSS counters, prefixing each item with "Step N:".

Example code

<!doctype html><html><head><meta charset="utf-8">
<style>ol{list-style:none;counter-reset:s;padding:0}li{counter-increment:s;color:#e6e0ff;padding:4px}li::before{content:"Step " counter(s) ": ";color:#b388ff;font-weight:700}</style></head><body style="background:#06040d;padding:20px"><ol><li>read</li><li>build</li><li>ship</li></ol></body></html>
▶ Open the interactive comic issue
‹ Forms · Accent-Color · Color-SchemeContent · Generated Text · Attr() ›