- HTML comments are used to create remarks or documentation inside your code.
- They are never displayed in the browser. Only visible in code.
- They are also very helpful in debugging the code.
Programmers write comments along with code when the code becomes long and messy. Comments can help them as well as other programmers to understand the code.
Remember, html comments are written between <!-- and --> tags.
<!-- This is a comment -->
<p>HTML is so easy to learn.</p>
<!-- This is another sample comment -->
Comments are also useful in debugging or testing the code. You can simply comment out the portion of HTML code to avoid displaying in the browser.
In the example below I have commented out the second paragraph. Now, the browser will consider it as a comment and won’t display in the browser.
<p>This is first paragraph.</p>
<!--<p>This is second paragraph.</p>-->