Re: [CSSWG] Resolutions 2008-03-04 and 2008-03-11

On Mar 12, 2008, at 3:59 AM, Christoph Päper wrote:
> Also ':nth-child()' etc. probably will mostly be used with 'odd'  
> and 'even'.

I don't know that that is true. I will probably use it a lot to  
select single elements when the HTML I don't control does not have  
IDs or classes where I need them.


>> I personally wouldn't expect there to ever be space between the  
>> "2" and the "n".
>
> I would, if "2n" was expandable to "2*n": "2 * n", "2* n", "2 *n",  
> "2 n".
>
> David Baron proposed this earlier:
>
>   Legal Examples:
>     :nth-child( 3n + 1 )
>     :nth-child( +3n - 2 )
>     :nth-child( -n+ 6)
>     :nth-child( +6 )
>   Illegal Examples:
>     :nth-child(3 n)
>     :nth-child(+ 2n)
>     :nth-child(+ 2)
>
> Imagine making the addition (including its operator symbol)  
> implied, just like the multiplication. Which of the following  
> should be legal?
>
>   :nth-child(3n1)     -> :nth-child(3n+1)
>   :nth-child(3n 1)    -> :nth-child(3n+1)
>   :nth-child(3n +1)   -> :nth-child(3n+1)
>   :nth-child(3n -1)   -> :nth-child(3n-1)
>   :nth-child(+3n 1)   -> :nth-child(3n+1)
>   :nth-child(+3n +1)  -> :nth-child(3n+1)
>   :nth-child(+3n -1)  -> :nth-child(3n-1)
>   :nth-child(-3n 1)   -> :nth-child(-3n+1)
>   :nth-child(-3n +1)  -> :nth-child(-3n+1)
>   :nth-child(-3n -1)  -> :nth-child(-3n-1)
>   :nth-child(3n + -1) -> :nth-child(3n-1)
>   :nth-child(3n+ -1)  -> :nth-child(3n-1)
>   :nth-child(3n +-1)  -> :nth-child(3n-1)
>   :nth-child(3n+-1)   -> :nth-child(3n-1)

In mathematical notation, writing the number and variable together  
("3n", "2pi", etc.) is the same as writing them with a multiplication  
symbol ("3*n", "2*pi", etc.). But substituting a space a  
multiplication symbol ("3 n") does not mean the same thing, so that  
is what I meant by saying I would not ever expect there to be space  
between the "2" and the "n".

For the same reasoning, I don't think you can imply the +/- symbol,  
because it stops making sense in mathematical notation. This really  
is a mathematical formula, where "n" is the progressively larger  
number representing the number of times repeated so far, starting  
with zero and increasing by one with each iteration (when using "+").  
For each value of "n", solving the formula tells you which child  
number to apply the style to. If you replace the plus with a space  
(3n 1), then it stops making sense as a math formula, at least in my  
knowledge of mathematical notation.

I think the spec is not really that clear on the fact that this  
really is a mathematical formula in which n = {0,1,2,3,4...}, where  
solving the equation gives you the child number (assuming the child  
elements are numbered starting with 1). It never really comes out and  
says it that explicitly, even though it gives examples where a=1 or  
b=0 or a is negative, etc. and the math continues to work.

It seems to me that the entire contents of the parentheses could just  
be fed to a mathematical parser instead of tokenizing as units or  
whatever. If that was the case, then ":nth-child(3n+ -1)" should be  
allowed, as should other equivalencies that can be written with the  
same symbols, such as ":nth-child(-1 + 3n)".

Received on Wednesday, 12 March 2008 15:56:03 UTC