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: Thu, 12 Jan 2012 09:12:08 -0800
Message-ID: <CAAWBYDD3vK=2j59VYbvz=nO9f45fw4_LKP5MkXus+=ftyH5+Tg@mail.gmail.com>
To: Jack Smiley <zxcv_890@hotmail.com>
Cc: www-style@w3.org
On Wed, Jan 11, 2012 at 2:47 PM, Jack Smiley <zxcv_890@hotmail.com> wrote:
> Yes, I thought there was good reason... I just wish I could understand it!
> Would you (or another list member) be so kind as to flesh out this
> explanation a bit?

Here's a silly example:

<ul>
  <li>one
  <li class=skiptwo>maybe three?
  <li>four
</ul>
<style>
li.skiptwo { counter-increment: list-item 2; }
</style>

This works right now.  If, on the other hand, counter-increment's
effect happened *after* the counter value as actually used, you'd
instead have to put the .skiptwo class on the first li.

But really, the main reason is just that properties pretty much always
have an effect on the element they're specified on, and breaking that
pattern is confusing.

~TJ
Received on Thursday, 12 January 2012 17:20:39 GMT

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