Re: CSS3 Selector Limitations and Suggestions

> [Original Message]
> From: Lachlan Hunt <lhunt07@netscape.net>

>
> ernestcline@mindspring.com wrote:
>
> >> - Descendant Pseudo Classes -
> >>
> >> * :nth-descendant(an+b)
> >> <snip/>
> >
> > This can be done using the :rpt() pseudo-class you give later,
> >
> > E F:nth-descendant(an+b)
> > is equivalent to:
> > E > *:rpt(an+b-1) > F
>
> Yes, but I wanted a meaningful shorthand method of doing that.  A 
> repeating syntax would be shorthand, but because it can't be used in 
> place of all of these pseudo elements, I included :nth-descendant for 
> completeness and consistency with the existing -child and -of-type
classes.
>
> If you think about it,
> E > F:nth-child(an+b)
> is (almost) equivalent to:
> E > *:first-child + * + ... + F
> or with a repeating syntax like:
> E > *:first-child + *:rpt(an+b-1) + F
> but :nth-child provides a meaningful shorthand.

True, but note that :first-child and + both appeared in CSS 2,
while :nth-child() appeared in CSS3.  I'm not convinced
that :nth-descendant() is useful enough to warrant inclusion in CSS,
if a repeat function is included, but experience or the views of
multiple others could convince me.

> >> * :nth-last-descendant(an+b)
> >> <snip/>
> >
> > Can you give a use case of why one would want this selector?
> > You gave an example of how it would be used, but not why.
>
>   The :last-, :nth-last-descendant and equivalent -of-type classes 
> provide a kind of way to work up through the document tree from the 
> bottom to top (or from the leaves to the root), whereas current CSS can 
> only work down (with the exception of the :last- and nth-last-child and 
> -of-type classes)..
>
> Example:
>   When an author or CSS artist wants to apply style to elements that 
> have only a set number of, or no descendants in the document tree.
> For example:

You've given another example of how, but not why.
Why would an author wish to use this rule?
Please don't give another abstract example of how
it could be used.  You've made that abundantly clear,
but abstract examples can only answer the how question,
not the why question.

Why should a author wish to select a node that has an+b-1
levels of descendents?  Until that question is answered,
I can see absolutely no value in :nth-last-descendent().


<snip>abstract example</snip>

> >> - Descendant of Type Pseudo Classes -
> >>
> >> * :nth-descendant-of-type(an+b)
> >> <snip/>
> >
> > This can also be done using the :rpt() pseudo-class you give later,
> >
> > E F:nth-descendant(an+b)
> > is equivalent to:
> > E *:rpt(an+b)
>
> Not quite, because that would count additional nested tags of other 
> types, whereas the -of-type pseudo class only count elements of that 
> type.  It's just like the difference between :nth-child and nth-of-type.

Excuse, I am a victim of cut and paste, (Mine, not yours. I sent it out
before finishing.)

I meant to say:

E F:nth-descendant-of-type(an+b)
is equivalent to:
E F:rpt(an+b)

>   This also raises another question.  Should nth-of-type be renamed to 
> nth-child-of-type?  Since both -child and -of-type classes only apply to 
> children of an element, and also for consistency with future classes 
> like the proposed -descendant classes or anything else that may be 
> thought of with similarities to them.
>
> >> * :nth-last-descendant-of-type(an+b)
> >> <snip/>
> >
> > Again, can you give a use case of why one would want this selector?
> > You gave an example of how it would be used, but not why.
>
> Yes, Using the previous example by nesting some extra inline elements of 
> any kind within the <em> elements.  Then modify the CSS to use the 
> -of-type() classes and the result should be the same.

Again, you answer the how, but not the why.
Why would an author wish to select those particular elements?

I can see why an author might wish to use :nth-descendant()
and :nth-descendant-of-type() but with the :nth-last versions you
propose I can't why one would want to use them, altho I can see
how they would be used,

Received on Monday, 8 December 2003 12:54:27 UTC