HTML Comments


Comments are those parts of HTML document that are ignored by every web browser.We generally add comments for simplicity from coders point of view so that we can understand what a particular HTML part is about.

Method of writting HTML comments

<!---- Place your comment here --->

Example:

<!DOCTYPE html>
<html>
<head>
<title>
Description of comments </title>
</head>
<body>
<!---- Place your comment here ---->
<h3>This is heading.</h3>
<p>This is paragraph.</p>
</body>
</html>

Output:

This is heading.

This is paragraph.

Types of comments

  1. Valid Comments-comments written in way <!---- Your Code ----->
  2. Invalid Comments-comments leave some space before !.

Notations:

  • Conditional Comments-These comments describes such HTML documents that are executed by Internet Explorer only.
  • Software program Comments