Copyright © tutorialspoint.com

CSS - counter-increment

previous next


Description:

The counter-increment property sets how much the counter increments on each occurrence of a selector. Default increment is 1.

Possible Values:

Applies to:

All the HTML elements.

DOM Syntax:

object.style.counterIncrement="chapter 2";

Example:

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

h1:before {
    content: "Chapter " counter(chapter) ". ";
    counter-increment: chapter;  /* Add 1 to chapter */
    counter-reset: section;      /* Set section to 0 */
}
h2:before {
    content: counter(chapter) "." counter(section) " ";
    counter-increment: section;
}

previous next

Copyright © tutorialspoint.com