Comments in HTML
HTML comments are used to insert notes into the HTML code. These comments are not displayed in the browser and are helpful for:
- Describing the structure or purpose of the code
- Temporarily disabling parts of the code
- Leaving notes for yourself or other developers
✅
Syntax
<!--
This is a comment -->
You can also place comments on
multiple lines:
<!--
This is a multiline comment.
It helps explain more details in the code.
-->
📌 Example
<!DOCTYPE
html>
<html>
<head>
<title>HTML Comments Example</title>
</head>
<body>
<!-- Main heading of the page -->
<h1>Welcome to My Website</h1>
<p>This is a paragraph.</p>
<!--
<p>This paragraph is commented out
and won't appear on the webpage.</p>
-->
<!-- Note: Don’t forget to update this
section later -->
<footer>
<p>© 2025 My Website</p>
</footer>
</body>
</html>