demo · v138
Nested outline with counters()
The visual outline reads “1.2.3”, but a screen reader announces “Subsection 1.2.3” — because counters() works in the alt-text side of the slash. Toggle the document depth to feel the difference.
checking support…
- Foundations
- Why structure matters
- Counters and content
- The slash syntax
- Nested counters with counters()
- Practice
- Authoring
the new line
li::before {
/* Visual: "1.2.3" — Alt: "Subsection 1.2.3" */
content: counters(chap, ".", decimal) " "
/ "Subsection " counters(chap, ".", decimal);
}
Pre-138, alt-text inside content rejected the counter functions: you could only ship a literal string. Anything dynamic had to be duplicated as an aria-label at author time, which authors rarely did, so screen-reader users heard the raw numbers without context.