concept
Counter scope — CSS reference
A counter is scoped by the element that creates it and the inheritance of counter sets through the element tree. A reset on each separate section gives each section its own numbering. Counters are not JavaScript variables and do not modify DOM text.
Formal Syntax & Structure
css syntaxcss
section { counter-reset: n; } p { counter-increment: n; }Working Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>Counter scope</title><style>body{margin:0}#a{padding:8px;background:rgb(232,237,241);color:rgb(0,0,0);box-sizing:border-box}body{font:16px/1.5 sans-serif}#a{margin:16px;padding:8px 8px 8px 80px;background:white}li{padding-left:4px}section{counter-reset:n}p{counter-increment:n}p::before{content:counter(n) ": "}</style><body><section><p>ONE</p> <p>TWO</p></section><section><p>THREE</p></section></body></html>