- From: Lachlan Hunt <lhunt07@netscape.net>
- Date: Tue, 09 Dec 2003 14:35:59 +1100
- To: ernestcline@mindspring.com
- Cc: www-style@w3.org
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 diffucult 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. I may not be able to think of a great example of why it would be used, because I'm not a great CSS artist, but that doesn't mean that someone else won't find a really good use for these. > I meant to say: > > E F:nth-descendant-of-type(an+b) > is equivalent to: > E F:rpt(an+b) Yes, that is what I assumed when I first read it, although, I too made a mistake when I reread it and replied. I should have written that E F:rpt(an+b) would not only select one matching descendant, it would also select all following descendants. <body> <section> <!-- 1 --> <section> <!-- 2 --> <div> <section> <!-- 3 --> <section> <!-- 4 --> </section> </section> </div> </section> </section> </body> body section:nth-descendant-of-type(3) /* Should select section 3 only, whereas: */ body section:rpt(3) /* Or equivalent syntax: */ body section section section /* Will select sections 3 and 4. If there were no <div> element above, then :nth-descendant(3) should also select the same section. > 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, -- Summary -- I think if any of the -descendant- classes were included, the -last-descendant classes should at least be included for consistency with existing -child and -of-type classes. A repeating syntax, or other existing CSS could be used as a substitute for some of these classes, but not all of them: Pseudo Class Substitute Why Include? :first-descendant E > F Derived from nth-descendant Consistency with -child and -of-type :last-descendant (None) Mainly for consistency, and some authors may find a good use for it. :nth-descendant(n) E>*:rpt(n)>F Derived from nth-child OR: E>*>...>F for consistency with nth-descendant-of-type(n) :nth-last-descendant(n) (None) See :last-descendant :first-descendant-of-type (None) For selecting descendants based on the nested types See above example :last-descendant-of-type (None) derived from nth- and first-descendant for consistency with nth- and last-of-type :nth-descenant-of-type(n) (None) Derived from nth-descendant for consistency with nth-of-type :nth-last-d...-of-type(n) (None) See :last-descendant-of-type If there are actually substitues for some of those, please let me know, but I'm quite sure that any potential substitutes will differ slightly in their selectivity in some, not necessarily all cases. CYA ...Lachy!
Received on Monday, 8 December 2003 22:37:27 UTC