1. What are HTML Comments?
HTML comments are an important functionality of HTML markup. They allow to add some content in between the HTML markup that is not displayed to the front end user. While the comment is visible only to the developer of the web page. This HTML tag has importance and let the developer to add his some key points above or in between different sections. So, whenever he visits the markup in future, he will read the comment and promptly understand the succeeding markup. Seethe example below to understand the basic structure of a comment.
In the above example, you can see the comment has only opening and closing angular brackets unlike regular HTML tags. The content between the two dashes is the content of the comment.
2. HTML Comments Usage
The only use of comments is to put reminders or mnemonics in between your code. A comment is only readable by a programmer who has access to the code or markup. Meanwhile comments also help in debugging the source code, which is a great help of HTML markup. So we must use HTML comments properly to get the most out of it. See another example to make it clear.
HTML Comment Detailed Example
<!Doctype html> <html> <head> <title>HTML Comment</title> </head> <body> <h3>HTML Comments Heading</h3> <!--This paragraph needs a review--> <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.</p> </body> </html>
The above example will display its result as below. As you can see comments are not shown explaining the usability of this tag.