Open In App

HTML <!– … –> Tag

Last Updated : 18 Apr, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

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.

html




<!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

HTML Single line Comment Output

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

HTML




<!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

HTML Multiline Comment Output

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



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads