Open In App

HTML <!–…–> Tag

Improve
Improve
Like Article
Like
Save
Share
Report

HTML comment tag is used to insert comments in the HTML code. It is a good practice of coding so that the coders can get helpful to understand the complex code. The comment tag is useful during the debugging of codes.

Syntax:

<!-- Comments here -->

Example 1: Single-line comment used to increase the code readability.

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.



Last Updated : 29 Feb, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads