HTML Comments Tag

The HTML 'comments' tag is used for creating comments within your HTML code.

The comments tag is not actually an HTML element (it is specified elsewhere in the HTML specifications). However, comments are an integral part of any HTML document. They allow the author to add comments that aren't displayed to the end users.

These comments can assist the author in understanding the code. This is particularly useful if there's a lot of code, the author is new to a website, or if the author is modifying an HTML document that he/she hasn't updated for a long time, and needs a reminder about what various parts do.

Syntax

The Comments tag is written as <!-- --> with the comments inserted between the start and end tags. Note that the exclamation mark is only used in the start tag.

Like this:

Examples

Basic tag usage

Multiple Lines

There is no difference between tag usage whether you're commenting out one line or multiple lines. You still insert the comments between the start and end tags. You can even have the start and end tags on their own line. This can make your comments easier to read.

Formatting Comments

Some authors like to include other characters to format their comments and draw attention to certain parts.