HTML Comments

Comments are a good way to note down some very important things in a code or program. In HTML, it is great practice to comment on some important parts of the code so that people can easily understand the logic behind the codes and help to simplify things when the time comes for debugging or troubleshooting an error.

Singleline Comments

Comments in HTML are started with the tag <!– and end with the tag –> and the comment are places inside the tags.
Singleline comments are comments that lie on a single line.

<!-- This is a singleline comment -->

Mutliline Comments

Multiline comments are used to write comments that span multiple lines. The same starting tag <!– and closing tag –> are used for multiline comments.

<!-- This is a mutipleline comment
which spans over multiple lines -->

Conditional Comments

Conditional comments are sometimes used with HTML but they only work in Internet Explorer on Windows. These comments can be used for websites or codes targeting Windows user using Internet Explorer web browser.Specific version of Internet Explorer can also be targeted.

<!--[if IE 6]>
Conditional comments for Internet Explorer 6

Comment Tags

There is a comment tag in HTML. It is denoted by opening tag <comment> and closing tag </comment>. The problem with this again is that it is not supported by all browsers. Only a few web browsers support it at the moment.

<p> This is <comment>not</comment> the best way to comment</p>