Open In App

HTML <!– … –> Tag

HTML comment tag is used to insert comments in the HTML code. It is good coding practice as it helps developers to better understand complex code. Comments is useful during the debugging of the code.

Syntax:



<!-- Comments here -->

Note: The comment tag () is used for both single line and multiline comments.

 



Example 1: Basic example of Single Line Comment.




<!DOCTYPE html>
<html>
  
<head>
    <title>HTML Single line Comment </title>
</head>
  
<body>
    <h2>Welcome to GFG</h2>
  
    <!-- Paragraph Element -->
    <p>Single Line Comment</p>
</body>
  
</html>

Output: Commnets will not be visible in browsers.

HTML Single line Comment Output

Example 2: Multiline Comment is normally used for debugging by keeping content inside of comments.




<!DOCTYPE html>
<html>
  
<head>
    <title>HTML Comment Tag</title>
</head>
  
<body>
    <h2>Welcome To GFG</h2>
    <p>Multiline Comment</p>
    <!--
     <p>Default code has been loaded into the Editor.</p>
     <p>Default code has been loaded into the Editor.</p>
    -->
</body>
  
</html>

Output: Commnets will not be visible in browsers.

HTML Multiline Comment Output

Supported Browser: The browsers supported by HTML comment Tag are listed below.


Article Tags :