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

On Sun, Mar 15, 2009 at 7:33 PM, Boris Zbarsky <> wrote:
> Mike Wilson wrote:
>>> 2)  How does one define what the "selected subset" is?  Are we
>>> talking
>>>     about "children of the same parent that match the rest of the
>>>     selectors in this rule" or something along those lines?
>> I guess I was expecting the subset to be the children that is the
>> result of the simple selectors to the left of :nth-child within
>> the same sequence, ie "li.item" and "li:not([title])" in these rules:
>> > li.item:nth-child(odd)
>> > li:not([title]):nth-child(odd)
> So li.item:nth-child(odd) and li:nth-child(odd).item would match different
> sets of nodes?  That would be pretty confusing to me as a CSS author, and a
> pretty significant change from how CSS selectors generally work right now.

This ambiguity can be cleared up by explicitly specifying the subgroup
you're wanting to target.

In the OP, Mike wants to grab just the <li class="item">, and then
style the odd ones, ignoring any <li>s with another class.  A syntax
like this would make it explicit:

li:nth-match(odd, .item)

This would first grab all the <li>s, then specialize onto only those
with class="item" to number, so that the "odd" specifier only cares
about <li class="item"> elements.

The current :nth-child(foo) selector is equivalent to ":nth-match(foo,*)".

>>>     If so, how does this work when multiple :nth-child or
>>> :nth-of-type selectors are present?
>> Dunno, but my head definitely starts spinning ;-)
> Well... this is sort of a key part of the whole thing, no?

With my proposed syntax, there is no problem when multiple
:nth-match() selectors appear together.  Each one works exactly like a
normal :nth-child, just with a possibly reduced set of nodes to number
and select (reduced from the full set of children).


Received on Monday, 16 March 2009 02:21:03 UTC