comment tag

If you don't know what an element is or how you must use it, I recommend you read the "HTML tags and attributes" tutorial that you can find in the HTML tutorials section.

Table of contents

Description

The HTML comment tag is used to insert comments inside the document's code. These comments are not rendered by browsers, and therefore aren't visible for the end user. The main purpose of this feature is to let authors add explanations, reminders and other resources to help themselves and others in the process of editing the document. It's also commonly used to exclude some parts of the document from the rendering process during testing.

A comment consists of the following parts:

  1. The string "<!--", or comment start delimiter.
  2. A run of text representing the actual comment, respecting the following restrictions:
    1. must not start with a ">" character
    2. must not start with the string "->"
    3. must not contain the string "<!--"
    4. must not contain the string "-->"
    5. must not contain the string "--!>"
    6. must not end with the string "<!-"
  3. The string "-->", or comment end delimiter.

Examples

In the following example there's a simple comment in the code, the author inserted as a remainder. The comment is invisible when the document is rendered by the browser.

<p>This specification has been divided in three parts...</p>
<!-- Guys, here we should add a better description about the distribution of content in the spec... -->
<p>In the first section, you'll find...</p>

This specification has been divided in three parts...

In the first section, you'll find...

Now, a part of the document is being removed for being under consideration. This practice is useful in some situations, because the commented content isn't rendered in the document but it isn't deleted either; it's just a piece of content that's been excluded (or unpublished) from the document.

<p>The modification process is rather simple...</p>
<!--
<p>To modify the configuration you should:</p>
<ol>
  <li>Locate and open the configuration file in your favorite text editor.</li>
  <li>Find the parameter you want to modify and replace the value on the right by the new value.</li>
</ol>
-->

The modification process is rather simple...