Re: handling of HTML Comments in HTML style element

* 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 UTC