W3C home > Mailing lists > Public > www-style@w3.org > September 2007

Re: handling of HTML Comments in HTML style element

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Date: Sun, 02 Sep 2007 08:50:28 +0200
To: fantasai <fantasai.lists@inkedblade.net>
Cc: Christof Höke <csad7@t-online.de>, www-style@w3.org
Message-ID: <54mkd3dgmhkm24uolqfd9beppv1mk6vk6s@hive.bjoern.hoehrmann.de>

* fantasai wrote:
>> hope this is the right play to ask, well for the question:
>
>Yep. Interpretation of the CSS specs is a valid topic here. :)

This is out of scope of the CSS specification. The input to the CSS
processor is a sequence of characters; the specification of the style
element has to define how to turn the style elements content into a
sequence of characters; parsing of the character sequence then is the
same as if the same sequence was specified in a separate .css file.

>This means '<!--' and '-->' are allowed anywhere between style rules
>and @rules, so your style sheet should result in the following style
>rules:
>
>   1. body { color: red }
>   2. comment
>   3. body { color: blue }
>   4. body { color: pink }
>   5. comment
>   6. body { color: green }
>
>where rules 2 and 3 are invalid because they're each missing a declaration
>block. End result: body's color is green.

That wouldn't be my conclusion. You parse the first "comment" as a
selector, then you see "-->" which cannot be part of a selector but
also isn't the required "{", so the input cannot be parsed according
to the grammar and its meaning therfore undefined. There neither is
an error recovery rule that I could see (unfortunately, CSS 2.1 says
it does not define the meaning of input that cannot be parsed, but
goes on to define the meaning of input that cannot be parsed.).

Well, there is 4.1.7 which says "The selector (see also the section on
selectors) consists of everything up to (but not including) the first
left curly brace ({)" (which is false e.g. if the "{" is in a string,
e.g. in an attribute selector). With that reading you'd have:

   body             { color: red   }
   comment --> body { color: blue  } /* bad selector, ignored */
   body             { color: pink  }
   comment --> body { color: green } /* bad selector, ignored */

So you get pink if that is allowed and supported.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 
Received on Sunday, 2 September 2007 06:50:38 GMT

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