W3C home > Mailing lists > Public > www-style@w3.org > January 2012

Re: [CSS2.1] Why is counter incremented before it's used?

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 11 Jan 2012 12:53:56 -0800
Message-ID: <CAAWBYDAMYUJrykWsf7vZyMMK8zikC6CSUQNMUrGhSdmG8WT1uw@mail.gmail.com>
To: Jack Smiley <zxcv_890@hotmail.com>
Cc: www-style@w3.org
On Wed, Jan 11, 2012 at 12:20 PM, Jack Smiley <zxcv_890@hotmail.com> wrote:
> Why was the decision made to increment a counter before it's used? Doesn't
> it then make it more confusing to have to set the counter to one less than
> the desired starting number? Then again, you guys are very smart, so I'm
> guessing there's probably a good reason...

Because if you don't, then you can't vary the amount you're
incrementing by according to the element - you'd have to *predict*
what the next element wants to increment by in whatever the previous
element that touches that counter is.

It also just generally seems more intuitive that counter-increment on
an element affects the value of the counter *on that element*.  It
does lead to the slightly inconvenient fact that you need to set
counter-reset to one less than your desired first value, as you note,
but you have to choose whether to make -increment confusing, or
-reset.  My previous paragraph makes it clearer why -increment won.

~TJ
Received on Wednesday, 11 January 2012 20:54:52 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:48 GMT