HTML COMMENTS


  • HTML comments are text, phrases or sentences inside an
  • HTML file. They are only shown in codes and not rendered by a browser.


Why use HTML Comments?

  • HTML comments help both beginners and experienced web developers to easily organize their codes.
  • They act like sticky notes in HTML files.

How to write HTML Comments?

An HTML Comment starts with <!-- and ends with -->

It looks like this:

<! -- comments go here -->

Example:

<p>

Single line Comment <!-- single-line comment -->

</p>

<p>

Multi-line comment <!-- this is a multi-line comment

some phrases go here some phrases go here -->

</p>

<div> <!-- putting comments beside a start tag -->

  Sentences, HTML elements and images etc.. may appear here.

 </div> <!-- putting comments beside a start -->

Output:

Single line comemnt

Multi-line comment

Sentences, HTML elements and images etc.. may appear here.

    On the example given above, you have learned that you can make a single-line and multi-line of HTML comments. And if you noticed we also put comments beside a start and end tag.


That is for us to easily recognize where a specific element starts and ends.