Himas Rafeek
Posted on: 3 years ago
CSS

CSS counter styling

two properties:

* counter-reset

* counter-increment

This example shows a way to number chapters and sections with “Chapter 1”, “1.1”, “1.2”, etc.


                                          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;
}