Forum How do I...?

counters being reset in every section?

dsusco
I have a counter that increments for every heading of a certain class. It worked great through a document, up until I added section tags (so I could specify one or two columns) and put the headings in them.

It used to do this with the old markup:

body
h1 - 1
h3 - 2
h1 - 3
h2 - 4
h3 - 5

With the new markup it's doing this:

body
section
h1 - 1
h3 - 2
section
h1 - 1
h2 - 2
h3 - 3

Any idea how I can stop it, I'm assuming through the rule to increment it?
mikeday
Are you still resetting the counters on the body element only?
dsusco
The counter is never reset, only incremented on the headers with the class.
mikeday
In that case it will create a new counter scope when you increment it that will apply to the current element and all of its following siblings. This scope will not apply to its ancestors, so the section nesting will end the counter scope and the next increment will create a new scope. So you need to reset the counter on the body, or the first section perhaps, to create a scope that will last the whole document.