Re: CSS3 Selector Limitations and Suggestions

> [Original Message]
> From: Lachlan Hunt <lhunt07@netscape.net>
>
> ernestcline@mindspring.com wrote:
>
>  >>>> * :nth-last-descendant(an+b)
>  >>
>  >> <snip>an example of use...</snip>
>  >
>  > You've given another example of how, but not why.
>  > Why would an author wish to use this rule?...
>  > but abstract examples can only answer the how question,
>  > not the why question...
>
>   I thought the how would also show why, but I'm finding it difficult to 
> give an exact reason why, without giving another abstract example that 
> show's how to use it.  The best reason I can think of to include the 
> -last-descendant classes is simply for consistency with the -child and 
> -of-type classes.

If its simply for consistency, then that is in my opinion the worst reason.

And now for the bad news.  Your proposal simply won't work as you intend.

Consider the following example:

<E id="a">
  <F id="b">
    <F id="c"/>
  </F>
</E>

You want E F:first-descendent to select just the element with id="b".
You want F F:first-descendent to select just the element with id="c".

However, the rules for selector syntax [1] state that:

A selector consisting of a single sequence of simple selectors
represents any element satisfying its requirements. Prepending
another sequence of simple selectors and a combinator to a
sequence imposes additional matching constraints, so the
subjects of a selector are always a subset of the elements
represented by the rightmost sequence of simple selectors.

Thus F:first-descendent must select both of the F elements,
as does E F:first-descendent which is not what you intend.

It looks like you'll have to go back to your combinator idea,
as given the fact that :not() is limited to a single simple selector
I see no way that a pseudoclass of the complexity that would
be needed would be approved.

[1] http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#selector-syntax

Received on Tuesday, 9 December 2003 00:05:25 UTC