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

Re: handling of HTML Comments in HTML style element

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Sun, 02 Sep 2007 02:01:19 -0500
Message-ID: <46DA5FBF.3030809@mit.edu>
To: fantasai <fantasai.lists@inkedblade.net>
CC: www-style@w3.org

fantasai wrote:
> The grammar defines the tokens
> 
>   CDO  <!--
>   CDC  -->
> 
> then it defines a style sheet as
> 
>   stylesheet  : [ CDO | CDC | S | statement ]*;

I seem to recall that this has come up in the past on this list and it was 
concluded that the grammar, as written, is wrong.  The idea of allowing these at 
all is to allow CDO at the beginning of inline stylesheets (_not_ all 
stylesheets) and allow CDC at the end of inline stylesheets (again not all 
stylesheets).  Has that decision been changed?  Or am I recalling incorrectly?

That all said, section 4.1.9 just says that CDO and CDC are allowed in a 
stylesheet production by the grammar (which is true).  The grammar itself points 
to Appending G, which defines CSS 2.1.  Note that this is slightly more 
restrictive, and in particular that according to this grammar the string

   body { color: red }
   <!-- comment -->
   body { color: blue }

Does not actually match the stylesheet production.  Indeed, for it to match the 
string "comment" would need to match one of the productions "ruleset", "media", 
and "page", and it doesn't match any of those.

I'm not certain that it's ever been clearly concluded what to do with strings 
that do not match the stylesheet production.

> 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

Sorry, but no.  That doesn't follow from the only thing we can actually conclude 
about our string, which is that it doesn't match the "stylesheet" production of 
CSS2.1.

> I think this would make a very good test for the test suite, btw.

Once we figure out what the heck the right behavior is, absolutely.  ;)

-Boris
Received on Sunday, 2 September 2007 07:01:41 GMT

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