- From: Mike Wilson <mikewse@hotmail.com>
- Date: Sat, 14 Mar 2009 14:44:35 +0100
- To: "'www-style'" <www-style@w3.org>
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 UTC