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

On Tue, Dec 27, 2011 at 22:43, Peng Yu <pengyu.ut@gmail.com> wrote:

> Hi,
>
> 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.
>

The correct way to select that would be with div.100\.100. The '.'
character has a special meaning in CSS, so it needs to be escaped to use it
literally.
Last time I tried, these escapes worked even on IE4.

Note that the div.100.100 selector is not invalid, just wrong (it's
perfectly legal, but it won't do what you would expect it to do at first
glance). It will select div elements that have a class '100' and also have
a class '100'. Essentially you are checking the class twice for the same
value. It would match elements like <div class="100"></div>.


>
> Do I miss anything in the document? Or this is discussed in some other
> document that I'm not aware of.
>
> --
> Regards,
> Peng
>
>
>

Received on Tuesday, 27 December 2011 23:35:28 UTC