Search code examples
htmlvalidationcommentsspecifications

Does using -- anywhere inside an HTML Comment make the Comment invalid HTML?


View Source in Firefox 78.0.1 is suggesting to me that if I use -- inside a multi-line HTML comment, it renders the comment invalid HTML.

That is:

<!-- 

  multiline

  comment

  here

-->

is valid, but this:

<!-- 

  -- multiline

  -- comment

  -- here

-->

is not.

Is this right?

I've searched Stack Overflow and the web and I'm unable to find authoritative confirmation of the requirement that an <!-- HTML comment --> must not contain -- anywhere apart from the very beginning and the very end.


Added:

I note that Chrome 83 does not have a problem with it.

Is it possible that Firefox 78 is mis-flagging a false positive?


Solution

  • I think that it is because Firefox 78 uses the W3C validator, which has a parsing error when searching for errors in comments. So, it is just misflagging false positives. I assume that this will probably be fixed at some point but, for now, I would suggest either ignoring it or using a different browser, as Firefox is the only one I can find which automatically uses the W3C.