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

Re: handling of HTML Comments in HTML style element

From: Tomas Kuliavas <tokul@users.sourceforge.net>
Date: Sat, 1 Sep 2007 23:38:40 +0300 (EEST)
Message-ID: <34050.78.61.224.253.1188679120.squirrel@avilys.eik.lt>
To: www-style@w3.org

>
> hi,
> hope this is the right play to ask, well for the question:
>
> How should the following excerpt from a simple HTML page be working:
>
>        <style type="text/css">
>                body { color: red }
>                <!-- comment -->
>                body { color: blue }
>                body { color: pink }
>                <!-- comment -->
>                body { color: green }
>            </style>
>
> (see http://cthedot.de/xbrowsertest/css.html for the complete page)
>
> At least one browser (Firefox) does seem to interpret the spec
> differently than most other browsers (at least IE, Opera, have not
> testet Safari).
>
> It seems Firefox invalidates the first CSS statement following a HTML
> comment so the resulting text is pinc which is defined in the 2nd
> following statement.
>
> As far as I understand the spec <!-- and --> in CSS Stylesheets should
> be ignored so it would lead to the following sheet:
>
>                body { color: red }
>                comment
>                body { color: blue }
>                body { color: pink }
>                comment
>                body { color: green }
>
> which definitely has errors in it. But how should the following
> statement be handled now? Ignored as Firefox does it or acknowledged as
> others do it?

http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fcthedot.de%2Fxbrowsertest%2Fcss.html&warning=1&profile=css21&usermedium=all

Your test only shows that firefox actually handles css errors better than
others or at least it is closer to w3.org css validator.

According to CSS1 specification CSS uses C style comments '/* */'. And
<!-- --> comments are used for html agents that don't understand <style>
tags.


<style type="text/css">
<!--
   body { color: red }
   /* comment */
   body { color: blue }
   body { color: rgb(255, 192, 203) }
   /* comment */
   body { color: green }
-->
</style>
Received on Monday, 3 September 2007 16:34:46 GMT

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