Comments in HTML



Comment lines are indicated by the special beginning tag <!-- and ending tag --> placed at the beginning and end of EVERY section of the document to be treated as a comment. Comments do not nest, and the double-dash sequence "--" may not appear inside a comment tag.

You must also make sure that there are no spaces in the start-of-comment string.

For example, the line

   <!--   This is commented out -->
is a valid comment line, but the line
   < !--   This is NOT commented out -->
is not, since there is a space between the left angle bracket and the exclamation mark.

Be careful if you use comments to "comment out" HTML that would otherwise be shown to the user, since some older browsers will still pay attention to angle brackets inside the comment and close the comment prematurely. The moral is -- test the documents before making them public!