- - - By CrazyStat - - -

22. April 2015

HTML5: why is my comment a ‘bogus comment’!?

Filed under: Uncategorized — Tags: , , , , — Christopher Kramer @ 12:52

I checked the validity of an HTML5 document (using the HTML Validator extension for Firefox, which I highly recommend) and found an error about a “bogus comment”. The comment looked normal:

<!–– some comment ––>

Then I read the HTML5 specification and found out that the bogus comment state instead of the “normal” comment state is entered if after “<!”, the parser cannot find two dashes. I remembered that I had copied the comment from the web and not typed it myself, so I deleted the –– and typed them manually. Looking closely, you can see the difference:

<!–– some comment ––>
<!-- some comment -->

After that, the bogus comment error was gone.

So the reason was that the – signs were not “normal”, but some other characters for longer dashes that look similar. So whenever you see a “bogus comment”, try to type the comment tags yourself…

Hope this helps somebody.


Try my Open Source PHP visitor analytics script CrazyStat.