codegurukool.com · Free coding tutorials & online compiler

Home › CSS Tutorial › CSS counters

CSS counters

Number things automatically.

Create with counter-reset, increase with counter-increment, and show with counter() in content.

Example code

<style>
body{counter-reset:s}h3::before{counter-increment:s;content:'Section ' counter(s) ': '}
</style>
<h3>Intro</h3><h3>Body</h3><h3>End</h3>

Run this code in the online editor

← CSS formsCSS inheritance →