HTML | Comments
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:
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




