You can add counters to a style sheet and increment them each time a certain HTML element is found. This is useful for automatically printing chapter and paragraph numbers. Works only in combination with :before and :after.
Testsheet:
div:before { counter-increment: div; counter-reset: par; content: "DIV number " counter(div) " "; } div p:before { counter-increment: par; content: "P number " counter(div) "." counter(par) " "; }
containing a paragraph
and yet another
containing a paragraph
and yet another