How to Write Comments in HTML Code

 | 

Comments in HTML code are used to notify or remind something the coder/ user. The HTML comment element <!-- --> is used to insert comments in HTML code.


HTML Comments

HTML Comment Tag

Using HTML comment tag, we can insert comments in HTML code. The HTML comment tag isn’t a closed tag, which means it doesn’t have a closing tag.

HTML comment tag always start with <!-- and ends with -->. Note that the ending part of the HTML comment tag doesn’t has a exclamation mark ! as in the starting half. Hence whatever text included in between <!-- and --> acts as a HTML comment.

HTML comments are not rendered by the browser but visible to anyone that views the page source code. Hence the HTML comments can be used for better documentation and debugging of the HTML source code.

Sample Code

<!-- paragraph starts-->
<p>This is a paragraph.</p>
<!-- paragraph ends-->

This is a paragraph.

Foot Notes

Comments