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

Re: Recommended practice on selector compatibility

From: Ian Hickson <ian@hixie.ch>
Date: Wed, 4 Dec 2002 02:17:20 +0000 (GMT)
To: Christian Roth <roth@visualclick.de>
Cc: www-style Mailing List <www-style@w3.org>
Message-ID: <Pine.LNX.4.21.0212040157300.7980-100000@dhalsim.dreamhost.com>

On Tue, 3 Dec 2002, Christian Roth wrote:
> 
> How does one best formulate the selector for a class named 'heading 1'?

Classes are space separated lists of words, so that is actually two
classes, "1" and "heading". You can match it using any of:

   .heading.1
   .1.heading
   [class=~"heading"][class=~"1"] /* CSS2 only */
   [class=~"1"][class=~"heading"] /* CSS2 only */

You can also ignore the semantics of the class attribute and match the
entire thing as one string using:

   [class="heading 1"] /* CSS2 only */

...but that wouldn't match the semantically identical class="1 heading".

> How do I tell a CSS3 parser that \0020 is a CSS2 conformant, maximum 4
> char escape sequence and the trailing '1' is the next literal
> character?

By following the escape with a space (which is ignored), as in:

   "\0041 B"

...which is identical to:

   "AB"


> Also, the .classname shorthand seems only to be defined for HTML
> documents

To be precise, "." is defined for any language which explicitly states
that it has an attribute that this selector applies to, which so far
includes, to the best of my knowlegde, HTML, XHTML, SVG, MathML, and XUL.


> What I have thought of would be something like
> 
>   .heading\00201, *[class=heading\0000201] { ... }
> 
> Is this correct CSS and, more specifically, is this a viable solution?

This will not be recognised by a CSS1 UA, since it doesn't recognise the
bit after the comma and therefore ignores the entire rule.

-- 
Ian Hickson                                      )\._.,--....,'``.    fL
"meow"                                          /,   _.. \   _\  ;`._ ,.
http://index.hixie.ch/                         `._.-(,_..'--(,_..'`-.;.'
Received on Tuesday, 3 December 2002 21:17:27 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:17 GMT