HTML comments are not visible to user, because it is not processed or rendered by web browser.
It is used by developers to document or make notes or add instructions to the source code which makes source code more readable and friendly, and also it can be used to stop execution of source code by web browser. HTML provides two types of comments single line and multi-line comments.

  1. Single line comments
  2. Multi line line comments

Single line comments

used to comment one line.

<!- This is single line comment -->
<!DOCTYPE html>
<html>
<body>
    
    <!--single line comment example-->
    <h2>single line comment is written in source code</h2>

</body>
</html>

Multi line comments

used to comment more than one lines.

<!- This is 
     multi line comment 
-->
<!DOCTYPE html>
<html>
<body>
    
    <!--multi line 
	comment example
     -->
    <div></div>

</body>
</html>

Stop source code or part of code to execute

HTML comments can also be used to stop execution of a part of code. mainly used for testing and debugging purpose.

<!--
<div>
This is not going to display in web browser, because this block is commented
</div>
-->
<!DOCTYPE html>
<html>
<body>
    
 <div>
    <!--
      <p> This tag will not be processed because it is commented </p>
     -->
  </div>

</body>
</html>