- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Tue, 20 Oct 2009 09:57:25 -0500
- To: www-style list <www-style@w3.org>
The relevant text from css3-selectors: The :nth-child(an+b) pseudo-class notation represents an element that has an+b-1 siblings before it in the document tree, for a given positive integer or zero value of n, and has a parent element. In other words, this matches the bth child of an element after all the children have been split into groups of a elements each. For example, this allows the selectors to address every other row in a table, and could be used to alternate the color of paragraph text in a cycle of four. The a and b values must be zero, negative integers or positive integers. The index of the first child of an element is 1. We noticed two possibles issues in the chatroom today. First, the prose says an+b matches "the bth child of an element after all the children have been split into groups of a elements each". This doesn't work correctly when b=0, as there is either no bth-child (if we assume that the later sentence about 1-numbering is to be taken here as well), or it specifies the wrong elements (if we assume 0-numbering). Second, what should happen when a and b are both 0? This matches no elements, since it evaluates to 0 and the first element is 1. However, Opera drops the rule entirely, rather than keeping it around as a rule that simply matches nothing. ~TJ
Received on Tuesday, 20 October 2009 14:58:21 UTC