HTML Comments are used to insert comments in the HTML code. It is a good practice of coding so that the coder and the reader can get help to understand the code. It is a simple piece of code that is wiped off (ignored) by web browsers i.e., not displayed by the browser.
There are three types of comments in HTML which are:
We will explore different types of Comments with suitable examples.
 The single-line comment is given inside the ( <!–  comment –> ) tag.Â
Syntax
<!-- Â comment -->
Example: In this example, we will see the implementation of the above approach.
HTML
<!DOCTYPE html>
<html>
<body>
<h1>GeeksforGeeks</h1>
<h2>This is single line comment</h2>
</body>
</html>
|
Output:

Multiple lines can be given by the syntax (<!– –>), Basically it’s the same as we used in single line comment, difference is half part of the comment (” –> “), is appended where the intended comment line ends.Â
Syntax
<!-- Â Multi
Line
Comment -->
Example: In this example, we will see the implementation of above approach.
HTML
<!DOCTYPE html>
<html>
<body>
<h1>GeeksforGeeks</h1>
<h2>This is multi-line comment</h2>
</body>
</html>
|
Output:Â

There used to be an HTML <comment> tag, but currently it is not supported by any modern browser.
Syntax
<comment> Some Comment </comment>
Example: In this example, we will see the implementation of above approach.
HTML
<!DOCTYPE html>
<html>
<body>
<comment>This is heading tag</comment>
<h1>GeeksforGeeks</h1>
<comment>This is multi-line
comment
</comment>
<h2>This is a comment using</h2>
</body>
</html>
|
Output:

Learn to code easily with our course
Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated :
13 Dec, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...