Re: [css3-selectors] details of :nth-child() syntax

L. David Baron wrote:
> I found a few issues in the description of the syntax of
> :nth-child() in
> http://www.w3.org/TR/2005/WD-css3-selectors-20051215/#nth-child-pseudo
> 
> I found two cases where the normative description of the syntax
> disagrees with the examples given.  I think the intent is pretty
> clear from the examples and we should fix the normative text.  In
> particular, I propose:
> 
> (1) Changing:
>   # When <var>a</var>=0, the <var>a</var><code>n</code> part need
>   # not be included, so the syntax simplifies to
>   # <code>:nth-child(<var>b</var>)</code> and the last example
>   # simplifies to <code>:nth-child(5)</code>.
> to read:
>   # When <var>a</var>=0, the <var>a</var><code>n</code> part need not be
>   # included.  When <var>a</var><code>n</code> is not included, the
>   # <code>+</code> sign before <var>b</var> (when allowed) may also be
>   # omitted.  In this case the syntax simplifies to
>   # <code>:nth-child(<var>b</var>)</code> and the last example
>   # simplifies to <code>:nth-child(5)</code>.
> Without this change, I think the normative text forbids
> :nth-child(5), requiring instead that the author write
> :nth-child(+5).

Fixed.

> (2) Changing:
>   # If b=0, then every ath element is picked. In such a case, the b
>   # part may be omitted. 
> to instead say:
>   # If b=0, then every ath element is picked. In such a case, the +b
>   # part may be omitted. 
> Without this change, it seems like authors would be required to
> write :nth-child(2n+) rather than :nth-child(2n).

Fixed. Wrote
   # If b=0, then every ath element is picked. In such a case, the +b
   # (or -b) part may be omitted unless the a part is already omitted.

> There are also two issues that I find unclear:
> 
> (3) Is -0 allowed as a value for a and/or b?  If so, the sentence:
>   # When the value b is negative, the "+" character in the
>   # expression must be removed (it is effectively replaced by the
>   # "-" character indicating the negative value of b).
> should be clarified to say that :nth-child(n+-0) is not allowed.  If
> not, the sentence:
>   # The a and b values must be zero, negative integers or positive
>   # integers.
> should probably clarified to say that zero may not be preceded by a
> minus sign.

Fixed by replacing
   # When the value b is negative
with
   # When the value b is preceded by a negative sign

> (4) The spec says:
>   # If both a and b are equal to zero, the pseudo-class represents
>   # no element in the document tree.
> When both are zero, the spec technically allows both to be omitted.
> This means :nth-child() is the same as :nth-child(0) and
> :nth-child(0n) and :nth-child(0n+0).  Is this intentional, or should
> it only be possible to omit one and not both (i.e., omitting both
> would be a syntax error)?  Either way, I think it should be stated
> explicitly.

Clarified by adding "unless the {a|b} part is already omitted" to both
statements about omitting parts.

~fantasai

Received on Thursday, 16 October 2008 12:02:16 UTC