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

css3 :nth-child() WD

From: Jonas Sicking <sicking@bigfoot.com>
Date: Wed, 28 Feb 2001 22:55:46 +0100
Message-ID: <003501c0a1d1$34a2dfa0$5412a8c0@Milwork08>
To: <www-style@w3.org>
First of all, sorry for posting this so close to the deadline.

I'm very impressed by the draft as a whole (especially :not ), however there
is one thing that I find a bit strange.

The syntax for :nth-child(an+b) when a or b is negative is a bit
unintuitive. I'm guessing the syntax was designed to allow selecting ranges
of objects, such as :nth-child(-n+6) to select the first six children.
However I think the synax isn't very easy to read and also requires three
psudos to match "child 3 to 5":
:nth-child(-n+5):not(:nth-child(-n+2))


I propose the following synax instead
:nth-child(an+b to c)
where a, b and c must be positive or zero. That would allow the following
selectors

:nth-child(2n+1) /* every odd child */
:nth-child(4n) /* every fourth child child */
:nth-child(5n+2 to 3) /* child number 2,3,7,8,12,13.... */
:nth-child(10 to 20) /* child 10,11...20 */
:nth-child(5n+0 to 4) /* selects every child */
:nth-child(2n+3) /* every odd child */

The definition would in other words be that that the selector matches if
there is an+b-1 to an+c-1 children before in the document tree for integer
n. Optionally b and c could be restriced to be less then a (unless a=0).

This syntax however could not match :nth-child(-2n+6) from the current WD
without using two pseudos :
:nth-child(even):nth-child(1 to 6)

But I think that wanting to match "child 3 to 5" is more common then "every
even child less then 6"




On a completly other topic: I think the :empty pseudo need some definition
of what is considered empty. Which of the following elements are considered
empty?
<E>   </E>
<E xml:space="preserve">   </E>
<E><!-- comment --></E>
<E><?myPI?></E>

<!ENTITY emptyEntity "">
<!ENTITY wsEntity "   ">
<E>&emptyEntity;</E>
<E>&wsEntity;</E>


/ Jonas Sicking
Received on Wednesday, 28 February 2001 16:55:40 GMT

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