HTML | Comments
It is used for inserting comments in the HTML code. Using comments, especially in complex code, is the best practice of coding so that coder and reader can get help for understanding. Commenting in codes is helpful during debugging.
- It is simple piece of code which is wiped off(ignore) by web browsers i.e, not displayed by browser.
- It helps to coder and reader of code to identify piece of code used for specially in complex source code.
Syntax of HTML Comments :
<!-- Write your comments here --> |
Types of HTML Comments :There are three types of Comments
- Single-line comments
- Multi-lines comments
- Using comment tag
- Single-line comments:
<!DOCTYPE html><html><head></head><body><!-- there is a comment --><p>geeksforgeeks.</p></body></html>chevron_rightfilter_noneOutput:
geeksforgeeks.
Here you can see the single-line comment.
- Multi-lines comments:
we can comment by using multilines too.Let’s see example:
<!DOCTYPE html><html><head></head><body><!--This is themultiline commentand this is the way of writing comments too.--><p>GeeksforGeeks</p></body></html>chevron_rightfilter_noneOutput:
GeeksforGeeks
Here we can see that in comment section we have used multi lines but still it’s not printed.
- Using comment tag:
There are few browsers that support <comment> tag, Internet Explorer is one of them.Let’s see example:
<!DOCTYPE html><html><head></head><body><p>This is <comment>not</comment> Internet Explorer.</p></body></html>chevron_rightfilter_noneOutput :
If we use Internet Explorer, then it will show following result :This is Internet Explorer.
But when we don’t use Internet Explorer, then it will show following result:-
This is not Internet Explorer
Supported Browser: The browser supported by <!–Comment–> tag are listed bellow :
- 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.



