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

Re: On nth-child, etc..

From: fantasai <fantasai@escape.com>
Date: Sat, 10 Mar 2001 12:40:11 -0500
Message-ID: <3AAA66FB.C0B96532@escape.com>
To: www-style@w3.org
Jonas Sicking wrote:
> 
> I totally agree with you, I first saw using negative indexnumbers in perl
> and have loved the syntax ever since. However it dosn't really fit nicly
> with the an+b synax, though it surly could be done. The following syntax
> could be used:
> :nth-child(-1..10)  /* ten last children */
> :nth-child(-3n-1)  /* same as 3n+1 (1,4,7...) but count from behind */
> :nth-child(-3n+1)  /* same as 3n-1 (2,5,8...) but count from behind */

IMO, the last ten children should be expressed as
  :nth-child(-1..-10)
This is more consistent and more logical. The range
should trace along the numberline, starting at b and
ending at c.

It also allows you to use :nth-child(7n-2..1) to mean
take every seventh, as well as two before and one after it -
  :nth-child(7n-2), :nth-child(7n-1), :nth-child(7n), :nth-child(7n+1)

> 
> so counting would be done from behind if the *first* number is negative.
> Unfortunatly the last two rules aren't very intuitive (but IMHO more logical
> then the current meaning of -3n+1).
> 
> You could also allow signs on the c constant which would also allow
> selectors like
> 
> :nth-child(5..-5) /* fifth child to fifth last child */
> 
> which the currently has to be done using either :not() or several rules
> "undoing" each other. 

Only two - :nth-child(n+5):nth-child(-n-5)

> However, what would a rule like :nth-child(-3n-1..10) mean?

As I see it, :nth-child(-3n-1), :nth-child(-3n), :nth-child(-3n+1..10)

~fantasai
Received on Saturday, 10 March 2001 12:38:58 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:08 GMT