The comment tag (<!– Comment –>) is used to insert comments in the HTML code. It is a good practice of coding so that coder and the reader can get help to understand the code. It is helpful to understand the complex code. The comment tag is useful during the debugging of codes.
- It is simple piece of code which is wiped off (ignore) by web browsers i.e, not displayed by browser.
- It helps the coder and reader to understand the piece of code used for specially in complex source code.
Syntax:
<!-- Comments here -->
Types of HTML Comments: There are three types of comments in HTML which are:
- Single-line comment
- Multi-lines comment
- Using <comment> tag
Single-line comment:
<!DOCTYPE html> <html> <head> <title> Single line comment </title> </head> <body> <!-- Paragraph element --> <p>GeeksforGeeks</p> </body> </html> |
Output:
GeeksforGeeks
Here you can see the single-line comment.
Multi-line comment: Multiple lines can be comment using (<!– –>) tag.
<!DOCTYPE html> <html> <head> <title> Multi-line comment </title> </head> <body> <!-- The multi-line comment is useful to comment multiple line Paragraph element --> <p>GeeksforGeeks</p> </body> </html> |
Output:
GeeksforGeeks
Here we can see that in the comment section we have used multiple lines but still it’s not printed.
Using <comment> tag: There are few browsers that support <comment> tag, Internet Explorer is one of them.
<!DOCTYPE html> <html> <head> <title> HTML comment tag </title> </head> <body> <p> This is <comment>not</comment> Internet Explorer. </p> </body> </html> |
Output:
If we use Internet Explorer, then it will show the following result:
This is Internet Explorer.
But when we don’t use Internet Explorer, then it will show the following result:
This is not Internet Explorer
Supported Browser: The browsers supported by <!– –> tag are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- How to write comments in HTML ?
- How to auto like all the comments on a facebook post using JavaScript ?
- JavaScript | Comments
- SASS | Comments
- CSS | Comments
- How to block comments in YAML ?
- HTML | <html> Tag
- HTML Course | Structure of an HTML Document
- HTML Course | Basics of HTML
- HTML | DOM HTML Object
- HTML | <html> xmlns Attribute
- What is the difference between <html lang="en'> and <html lang="en-US'> ?
- Inline HTML Helper - HTML Helpers in ASP.NET MVC
- HTML | scoped Attribute
- HTML | DOM lang Property
- HTML | <section> Tag
- HTML | DOM Style backgroundClip Property
- HTML | DOM Style borderTop Property
- HTML | <th> valign Attribute
- HTML | <col> align Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet


