[vox-tech] dumb html question
Micah Cowan
vox-tech@lists.lugod.org
Thu, 13 Dec 2001 13:20:44 -0800
On Thu, Dec 13, 2001 at 01:08:17PM -0800, Matt Roper wrote:
> I seem to recall that CSS (and JavaScript also) have two comment
> markers: "<!--" and "//". Both of these markers are only active until
> the end of the line, the same way "#" works in shell scripts.
"//" works that way, not "<!--". Also, technically, neither CSS nor
JavaScript use "<!--" - that's an SGML/XML comment. It would not be
recognized in standalone JavaScript or CSS documents.
> I think the problem with your first example is that <!-- kills
> everything on its line, so your STYLE tag really is empty (it only
> contains a comment). The problem with the second example is that
> "-->" has no meaning in CSS (it isn't an end of comment marker like
> it is in HTML) so the ">" at the end is getting interpreted
> strangely.
>
> What you want is:
>
> <STYLE type="text/css">
> <!--
> H1 {font-size: +33pt}
> // -->
> </STYLE>
This is frequently used - however, oddly enough it is not in the
example given in the HTML spec.
> Now the first and third lines inside the STYLE tag are comments as far
> as CSS browsers are concerned. Old browsers that don't understand CSS
> will simply think the whole thing is an HTML comment. Note that a CSS
> capable browser would accept
>
> <STYLE type="text/css">
> <!--
> H1 {font-size: +33pt}
> //
> </STYLE>
>
> just fine.
I don't think so. As I said, the "<!--" is interpreted by the HTML
parser, not the CSS parser - it's just that most browsers have a
"special case" in interpreting HTML comments within CSS. But most
browsers would still expect you to end your HTML comment.
Micah