Comments in any programming language is a block of notes or remarks, can be placed anywhere in the code to assist the programmer to understand why is this particular block of code has been written. HTML Comments increase the readability of the code, and helps other programmer to understand the code written by other programmer if it is properly commented.It is always a good practice to put comments into your source code.
Advantages of putting comments in HTML
- Comment out code temporarily rather than removing when it is not complete and could be used in future.
- Helps to put remarks on block of code.
- Helps other programmer to understand the source code.
- It helps debugging the code.
HTML Comments can be placed anywhere in the HTML file, it could be inside the head section or could be inside the body section, or in between the head and the body.HTML Comment Tags are different than other HTML Tags. HTML Comments always start with
<!-- and end with
-->. Comments never displayed on the browser.
<!-- Single line comment. -- >
First line of comment.
Second line of comment.
Multi line commenting.