Re: IE 5.5 Warning: CSS and comment tags

by =?iso-8859-1?Q?St=E9phane?= Bergeron <stephberg(at)videotron.ca>

 Date:  Mon, 17 Jul 2000 23:54:49 -0400
 To:  hwg-techniques(at)hwg.org
 Cc:  arcady(at)jps.net
 In-Reply-To:  jps
  todo: View Thread, Original
At 10:48 PM 17/07/00 +0000, you wrote:
>Hello;
>
>Had a client 'upgrade' (and I use the term loosely) to IE 5.5 over the=
 weekend
>and suddenly all the typography on their site was broken.
>
>It seems that in IE 5.5 you cannot put a comment tag in your .css files=
 that
>begins with // like commonly used for javascript comments.
>They must instead begin with /* and end with */

Actually, you _never_ could insert JavaScript-like comments in CSS and=20
always had to use /*...*/ as it's the only legal way to add comments in=20
CSS.  IE is not at fault here as it simply follows the spec and handles=20
what it sees as illegal elements (probably all that follows your //=20
comments) as it should. From the CSS1 spec:

"1.7 Comments
Textual comments in CSS style sheets are similar to those in the C=20
programming language [7]:
EM { color: red }  /* red, really red!! */
Comments cannot be nested. For a CSS1 parser, a comment is equivalent to=20
whitespace. "

... and from the CSS 2 spec:

"4.1.9 Comments
Comments begin with the characters "/*" and end with the characters "*/".=20
They may occur anywhere between tokens, and their contents have no=20
influence on the rendering. Comments may not be nested.
CSS also allows the SGML comment delimiters ("<!--" and "-->") in certain=20
places, but they do not delimit CSS comments. They are permitted so that=20
style rules appearing in an HTML source document (in the STYLE element) may=
=20
be hidden from pre-HTML 3.2 user agents. See the HTML 4.0 specification=20
([HTML40]) for more information. "

If you check the CSS 2 spec, the error handling bit appears right below the=
=20
comments one I copied above... if only NN 4.x could be more compliant with=
=20
that one... ;-)

Actually, I'm surprised that IE didn't give you problems with JavaScript=20
comments in your CSS files before as its CSS error handling is worlds=20
better than Netscape's and has been since IE 4.0.  Microsoft has improved=20
their standard support between IE 5.0 and IE 5.5 significantly and even if=
=20
it's still not perfect, it's still the best there is on Windows by far=20
(IMO).  Only Opera 4.01 is at par or better in certain areas.  The one=20
thing I really dislike about IE is that it's too forgiving with sloppy=20
code.  I'm happy to see they are improving this too.

>Just thought I'd inform people who didn't know this. I've got to revise a=
 few
>sites now before IE 5.5 spreads too far.

Sorry to rub it in but you'll only be fixing your own mistakes, not=20
IE's...  ;-)

HTH!

St=E9phane Bergeron

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA