Comments in HTML are used to add notes, explanations, or reminders inside the code.
They are not displayed in the browser — only visible in the page source.
Comments help developers understand, debug, and organize their HTML code easily.
The basic syntax of an HTML comment is:
<!-- This is a comment -->
Everything inside <!-- and --> is treated as a comment by the browser.
<!DOCTYPE html>
<html>
<head>
<title>HTML Comments Example</title>
</head>
<body>
<!-- Main heading of the page -->
<h1>Welcome to Learn2Kode</h1>
<!-- Paragraph about Learn2Kode -->
<p>We help you learn web development step by step!</p>
<!-- This comment will not be displayed in the browser -->
</body>
</html>
We help you learn web development step by step!
You can write comments that span multiple lines — just keep the content inside the same <!-- --> block.
<!--
This is a multi-line comment.
You can use it to explain complex code
or temporarily disable a section.
-->
Developers often use comments to disable (or “comment out”) code temporarily while testing.
<!-- <p>This paragraph is temporarily hidden.</p> -->