W3C home > Mailing lists > Public > www-style@w3.org > March 2009

[css3-selectors] structural child indexes vs rule selections

From: Mike Wilson <mikewse@hotmail.com>
Date: Sat, 14 Mar 2009 14:44:35 +0100
Message-ID: <BAY116-DAV6540CC9ECE3FC7B0A3558A49D0@phx.gbl>
To: "'www-style'" <www-style@w3.org>
Message-ID: <07f101c9a4ab$02f4f2a0$0a01a8c0@mikedeskxp>
Pardon me if this have been covered before, but has there been
any discussion on whether :nth-child (and other structural 
selectors) should be able to work on indexes from the selected
child subset rather than from the 'complete' child list?

Example targeting all <li>s:
  li.item:nth-child(odd) {background-color:grey;}
  <li class="item">a</li>  --> index 1 = odd = grey
  <li class="item">b</li>  --> index 2 = even
  <li class="item">c</li>  --> index 3 = odd = grey

Example targeting subset of <li>s:
  li.item:nth-child(odd) {background-color:grey;}
  <li>...</li>             --> index 1 (not selected)
  <li class="item">a</li>  --> index 2 = even
  <li class="item">b</li>  --> index 3 = odd = grey
  <li class="item">c</li>  --> index 4 = even

In the second example we see that the first <li> "consumes"
the first odd entry from the formating rule, although it is
not selected by this rule. This makes the whole striped
formating visually shift one step forward as a side effect of
introducing an element not covered by the rule.

Would it be desirable to instead count indexes based on 
the selected subset, like in:
  li.item:nth-child(odd) {background-color:grey;}
  <li>...</li>             --> (not selected)
  <li class="item">a</li>  --> index 1 = odd = grey
  <li class="item">b</li>  --> index 2 = even
  <li class="item">c</li>  --> index 3 = odd = grey
?

Best regards
Mike Wilson
Received on Saturday, 14 March 2009 13:45:45 GMT

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