Home HTML HTML Comments

HTML Comments

Comment

In HTML, comments are used to add notes or explanations to the code that are not displayed in the browser. Comments can be used to leave notes for yourself or other developers working on the same code, to temporarily disable certain parts of the code, or to explain how a specific piece of code works.

Syntax

				
					<!-- This is a comment -->

				
			

Everything between the opening <!-- and closing --> is considered a comment and will not be displayed in the browser.

Example

				
					<!DOCTYPE html>
<html>
<head>
  <title>My First HTML Page</title>
</head>
<body>
  <!-- This is a comment -->
  <h1>Welcome to my website!</h1>
  <p>This is my first webpage created using HTML.</p>
  <!-- This is another comment -->
</body>
</html>
				
			

As you can see, comments are not rendered by the browser and are only visible in the source code. They can be used to provide explanations or notes about the code, which can be helpful for other developers who are working on the same code, or for yourself when you return to the code later.

Scroll to Top