Typography
counter-increment
Increasing or decreasing the value of named CSS counters.
Overview
| Class | Declarations |
|---|---|
counter-increment:none | counter-increment: none;
|
counter-increment:<name> | counter-increment: <name>;
|
counter-increment:<name>|<integer> | counter-increment: <name> <integer>;
|
counter-increment:<name>|<integer>|<name>|<integer> | counter-increment: <name> <integer> <name> <integer>;
|
Basic usage
Number sections
Use counter-increment to advance a named counter on each matching element. The counter is usually created with counter-reset and displayed with content.
Overview
Introduce the document structure and goals.
Installation
Add the package and wire it into the build.
Configuration
Customize counters, selectors, and content output.
<article class="counter-reset:section"> <h2 class="counter-increment:section content:counter(section)::before inline-flex::before r:full::before">Overview</h2> <h2 class="counter-increment:section content:counter(section)::before inline-flex::before r:full::before">Installation</h2> <h2 class="counter-increment:section content:counter(section)::before inline-flex::before r:full::before">Configuration</h2></article>Count backward
Pass a negative integer to decrease a counter. Here the first generated value is 10 because the counter starts at 11 and decrements before it is displayed.
- Prepare release notes
- Run validation
- Publish the build
<ol class="counter-reset:step|11 list-style:none"> <li class="counter-increment:step|-1 content:counter(step)::before inline-flex::before r:full::before">Prepare release notes</li> <li class="counter-increment:step|-1 content:counter(step)::before inline-flex::before r:full::before">Run validation</li> <li class="counter-increment:step|-1 content:counter(step)::before inline-flex::before r:full::before">Publish the build</li></ol>Apply conditionally
Apply styles based on different states using selectors and conditional queries.
<div class="counter-increment:section:hover counter-increment:section@sm counter-increment:section@dark counter-increment:section@print">…</div>