Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@matveyt
Last active February 27, 2021 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matveyt/f7412e0a4378d970ffa67cf149e2e161 to your computer and use it in GitHub Desktop.
Save matveyt/f7412e0a4378d970ffa67cf149e2e161 to your computer and use it in GitHub Desktop.
HTML comments test
<!DOCTYPE html>
<html lang="en">
<head><meta charset="utf-8"/><title>HTML 5.2 comments test</title></head>
<body>
<pre>&lt;! -- Bogus comment --&gt;</pre>
<! -- Bogus comment -->
<p>8.2.4.41-42: parser error, normal continuation after next &gt;</p>
<pre>&lt;!--&gt;</pre>
<!-->
<p>8.2.4.43: parser error, normal continuation</p>
<pre>&lt;!---&gt;</pre>
<!--->
<p>8.2.4.44: parser error, normal continuation</p>
<pre>&lt;!--- Me -- is -- good -- comment ------&gt;</pre>
<!--- Me -- is -- good -- comment ------>
<p>8.2.4.51: this is all right even though validator may complain about document being
"not mappable to XML 1.0 due to consecutive hyphens"</p>
<pre>&lt;!-- Comment closed by dash-dash-bang --!&gt;</pre>
<!-- Comment closed by dash-dash-bang --!>
<p>8.2.4.52: error ignored even by parser, normal continuation</p>
<pre>&lt;!-- Comments cannot nest &lt;!---&gt; This is not a comment #1!</pre>
<!-- Comments cannot nest <!---> <p>This is not a comment #1!</p>
<pre>&lt;!-- Comments cannot nest &lt;!----&gt; This is not a comment #2!</pre>
<!-- Comments cannot nest <!----> <p>This is not a comment #2!</p>
<pre>&lt;!-- Comments cannot nest &lt;!--!&gt; This is not a comment #3!</pre>
<!-- Comments cannot nest <!--!> <p>This is not a comment #3!</p>
<pre>&lt;!-- Comments cannot nest &lt;!---!&gt; This is not a comment #4!</pre>
<!-- Comments cannot nest <!---!> <p>This is not a comment #4!</p>
<p>8.2.4.49: parser error, comment continues until next --&gt;.</p>
<p>However the following (taken from 8.1.6) is all right:</p>
<pre>&lt;!--My favorite operators are &gt; and &lt;!--&gt;</pre>
<!--My favorite operators are > and <!-->
<pre>&lt;!--This comment was intentionally left open -- &gt;
So it continues until here --&gt;</pre>
<!--This comment was intentionally left open -- >
So it continues until here -->
<p>But not here, of course.</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment