HyperText Markup Language
Previous

Comments

<!-- Comment -->


Since HTML is officially an SGML application, the comment syntax used in HTML documents is the same as the SGML comment syntax:

A comment declaration starts with <!, followed by zero or more comments, followed by >. A comment starts and ends with "--", and does not contain any occurrence of "--".
This means that the following are all legal SGML comments:
  1. <!-- Hello -->
  2. <!-- Hello -- -- Hello-->
  3. <!---->
  4. <!------ Hello -->
  5. <!>
Note that an "empty" comment tag, with just "--" characters, should always have a multiple of four "-" characters to be legal. (<!> is also a legal comment - it's the empty comment).

Use the following simple rule to compose valid and accepted comments:

An HTML comment begins with "<!--", ends with "-->" and does not contain "--" or ">" anywhere in the comment.


Go to:


Library of Congress
Library of Congress Help Desk (October 16, 2000)