HTML comments within comments?

Tony R picture Tony R · Sep 22, 2010 · Viewed 25.6k times · Source

Is there a way to comment multiple lines... which already have some comments in them?

i.e.

<html>
<!-- Multi-line comment begin
  <head>
    <!-- This script does abcxyz -->
    <script>...</script>
  </head>
  <body>
    Hello world!
  </body>
Multi-line comment end -->
</html>

It seems that even SO's syntax hilighting won't accept this...

Answer

&#193;lvaro Gonz&#225;lez picture Álvaro González · Sep 22, 2010

I think the key point is this:

Note that comments are markup.

http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.4

This is not valid markup:

<div <span/> />

... so neither is the one you mention.


Since all my sites are written in PHP I normally comment out code with PHP comments:

<?/*?>
<div>...</div>
<p>...</p>
<?*/?>

Perhaps you can use a similar trick.