/ Published in: CSS
two properties:
* counter-reset
* counter-increment
This example shows a way to number chapters and sections with "Chapter 1", "1.1", "1.2", etc.
* counter-reset
* counter-increment
This example shows a way to number chapters and sections with "Chapter 1", "1.1", "1.2", etc.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
body { counter-reset: chapter; /* Create a chapter counter scope */ } h1:before { content: "Chapter " counter(chapter) ". "; counter-increment: chapter; /* Add 1 to chapter */ } h1 { counter-reset: section; /* Set section to 0 */ } h2:before { content: counter(chapter) "." counter(section) " "; counter-increment: section; }
URL: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Counters