Re: "." in class selectors where class names have special characters

On Tue, Dec 27, 2011 at 3:31 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 12/27/11 4:43 PM, Peng Yu wrote:
>> http://www.w3.org/TR/CSS2
>>
>> The above document doesn't explain what characters are allowed when
>> "." is used as the class selectors. For example,
>>
>> <div class="100.100"></div>
>>
>> Selecting the above element by div.100.100 seems not to work.
>
>
> div.100\.100 should work fine.  This is covered in the spec you linked to.

Not quite - classes can't start with a digit.  You need to *also*
escape the first digit, producing a selector like:

div.\31 00\.100 { ... }

This is pretty ugly, of course.

Peng, you should avoid using classes that start with a digit or that
contain "special" characters.  Just use digits, letters, dashes, and
underscores for your classes, and don't start them with a digit.

~TJ

Received on Tuesday, 27 December 2011 23:47:47 UTC