W3C home > Mailing lists > Public > www-style@w3.org > July 2000

Re: css identifier parsing bugs, escapes in classnames

From: Bert Bos <Bert.Bos@sophia.inria.fr>
Date: Wed, 19 Jul 2000 16:37:31 +0200 (MEST)
To: "Bruno" <bruno@teraram.com>
Cc: <www-style@w3.org>
Message-ID: <14709.47267.244688.899232@lanalana.inria.fr>
Bruno writes:
> Could someone give me more informationa about that
> p.a\:b { color: purple }
> Where is "\" in CSS, where can I find examples of that "thing", what for is
> it anyway, I really did not understand you so can you explain it to me in
> details:)

OK, let me try:

The problem is that there is a difference in the values that HTML
allows in the CLASS attribute and what CSS allows after the dot in a
class selector. In most cases things work as you expect:

    <EM CLASS="intro77">


    EM.intro77 { color: red }

But HTML allows more or less any symbol apart from space, so you could
invent a class name like this:

    <EM CLASS="intro@77+1">


*   EM.intro@77+1 { color: red }

is illegal syntax in CSS, since "@" and "+" are reserved for other
things. To fix this, CSS allows the illegal symbols to be escaped:

    EM.intro\@77\+1 { color: red }

The backslash (\) basically means that whatever follows it should be
treated just like a letter.

See http://www.w3.org/TR/REC-CSS2/syndata.html#q4

  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos/                              W3C/INRIA
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France
Received on Wednesday, 19 July 2000 10:38:07 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:26:54 UTC