About Lesson
HTML Comments
HTML comment tag is used to insert comments in the HTML documents.
Comments are a piece of code that is ignored by the browser, but they can help document your HTML source code.
It is a good practice to add comments into your HTML code, especially in long and complex documents, to indicate sections of documents.
Comment Tag
- You can add one or more comments to your HTML document.
- Comments are represented by <!–– ––>.
- It is a good practice of coding to add comments to your HTML source code.
- Comments help the coder and other people to understand the Source code of the document.
- The comment tag is useful during the debugging of codes.
- Browsers automatically ignore comments, but they can help document your HTML source code.
Syntax
<!--This is the syntax of Single-line comment-->
Example :
<!DOCTYPE html>
<html>
<head>
<title>HTML comments</title>
</head>
<body>
<!--This is a comment-->
<p>This is a simple text</p>
</body>
</html>
Output
<!--This is a comment-->
This is a simple text