W3C home > Mailing lists > Public > www-style@w3.org > December 2011

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

From: Eduard Pascual <herenvardo@gmail.com>
Date: Wed, 28 Dec 2011 00:34:33 +0100
Message-ID: <CACb57T1TBhTh-reD32BN3+68Tf8Q0tWBqgoR-qOTQvYav51CBw@mail.gmail.com>
To: Peng Yu <pengyu.ut@gmail.com>
Cc: www-style@w3.org
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
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

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:08 UTC