Loading

KEYPOINTS

  • Comments are used to insert notes or explanations within the code that are not displayed on the webpage. 
  • Comments are helpful for developers to document their code, provide context, and make it easier to understand for others who might be working on the same project.

DEFINATION

HTML comments are piece of text that are not displayed in browser but can be seen by anyone who view the source code of the webpage. They are used to insert comments in the source code and can be used for various purposes, such as: 

  • Explaining code: Comments can help you when you edit the source code at a later date, especially if you have a lot of code. 
  • Adding notes: Comments can be used to leave notes for other developers. 
  • Hiding code: Comments can be used to disable parts of HTML code. 
  • Debugging errors: Comments can help streamline the troubleshooting process by enabling developers to pinpoint problematic areas.


Syntax:

<!-- Write your comments here -->

Example:

<!DOCTYPE html>
<html>
<body>

<!-- This is a comment -->
    <p>This is a paragraph.</p>
<!-- Comments are not displayed in the browser -->

</body>
</html>

Output:

This is a paragraph.