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

Re: On nth-child, etc..

From: fantasai <fantasai@escape.com>
Date: Wed, 18 Apr 2001 22:42:58 -0400
Message-ID: <3ADE50B2.4E923664@escape.com>
To: www-style@w3.org
fantasai wrote:
> I am arguing for
>   - the removal of :nth-last-child etc., with negative 
>     values taking its place
\
> 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)

Defining negative values to mean "count from the end"
yields some unexpected and odd results.
For example, :nth-child(7n-2..1) results in two negative
values when n=0, -1 and -2, causing the last two elements
to be selected, which is probably not the intent of the
author.

Given the general form An+B..C, this problem can be avoided 
by using A as a determinant:
  - if A > 0, then only positive results from the An+B..C
              expression will be processed; negative values
              are discarded
  - if A < 0, then only negative values are processed
  - if A = 0, then no restrictions are placed.
              Thus :nth-child(-5..5) selects the same 
              elements as :nth-child(1..5), :nth-child(-1..-5)
Received on Wednesday, 18 April 2001 22:41:36 GMT

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