views:

44

answers:

4

This is just question about comments inside of an HTML page.

For example:

<html>
    <head></head>
    <body>
    <!--
    <p><font size="4">--</font></p>
    -->
    </body>
</html>

Using http://validator.w3.org/check I get the following error message. Does it make sense?

Line 6, Column 21: invalid comment declaration: found character "<" outside comment but inside comment declaration

<p><font size="4">--</font></p>

Check that you are using a proper syntax for your comments, e.g: . This error may appear if you forget the last "--" to close one comment, and later open another.

+1  A: 

Looks like the string -- isn’t allowed within HTML comments.

Paul D. Waite
+4  A: 

Yes, it makes sense.

To understand the error message, you have to understand the comment tag. It consists of three key parts, the <! that starts the tag, the -- that starts and ends the comment, and the > that ends the tag.

When you put -- inside the text of a comment, you actually end the comment part. The rest of the text until the end of the tag is invalid, as it's not a comment, and you can only have comments inside the comment tag.

You can also have more than one comment in the tag:

<!-- comment -- -- another comment -->
Guffa
Ok, it does make sense now! I didn't know the comment tag had 3 parts. thanks.
+1  A: 

No, it does intuitively not make sense to most of the logical thinking humans, but the validator has it really right. The -- denotes a comment delimiter. Also see W3 validator bug 5555:

yes, really invalid. -- is a comment delimiter in XML.

BalusC
A: 

I think it's being confused by the two hyphens in the middle. The ones in >--<.

If you must have those, perhaps you could substitute the escape character &#45; for them.

DOK