HTML COMMENT


HTML comment is used to make a comment in an HTML document.

HTML comment is ignored by the browser. Anything written as a comment is not taken under consideration.

Anything written in between <!-- and --> is considered a comment.

Example:

<!-- This is comment and it ignored by browser -->
<p>This is a paragraph.</p>
Try It

Use of comment

In large HTML documents it is good to use comments for future convenience.

<!-- Content starts -->
<p>In long and complex HTML document you can add comments like this.</p>
<!-- Content ends -->
Try It

Correct way to add comment

There are something that we need to take care while creating comment:


<p>Comment is valid.</p>
      <!-- This is a valid comment -->
Try It

<p>This Comment is invalid.</p>
      <! -- This is a invalid comment -->
Try It

Multiline comment in HTML

Multiline comments span multiple lines where the line starts with <-- and ends with -->.

<p>Learning muliline comment.</p>
      <!-- This is a comment line 1 
          This is a comment line 2
          This is a comment line 3-->
Try It