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

Re: [css3-selectors] structural child indexes vs rule selections

From: Brad Kemper <brad.kemper@gmail.com>
Date: Sat, 14 Mar 2009 10:05:23 -0700
Message-Id: <A8FD539C-E678-41F2-83F0-7543F60999C6@gmail.com>
To: Mike Wilson <mikewse@hotmail.com>
Cc: www-style <www-style@w3.org>
It seems to me that would be a different feature. If you are basing  
the index on what is selected, instead of the DOM, then the items  
would not even need to be siblings in the DOM. You could call it 'nth- 
item' perhaps. As a new feature, it would not be included in Last Call  
changes, but could be a good future addition.


On Mar 14, 2009, at 6:44 AM, "Mike Wilson" <mikewse@hotmail.com> wrote:

> 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 17:06:04 GMT

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