tutorialstonight logo
A Platform To Learn To Code

HTML COMMENT



HTML comment is used to make a comment in an HTML document.

HTML comment is ignored by the browser. Anything written as a comment is not taken under consideration.

Anything written in between <!-- and --> is considered a comment.

Example:

Example

Run the code

Use of comment

In large HTML documents it is good to use comments for future convenience.

Example

Run the code

Correct way to add comment

There are something that we need to take care while creating comment:

  • Comments should not be nested inside any other comment.
  • There should not be two continuous dash like --.
  • There should be no gap in dash(-) and exclamation mark(!).


Example

Run the code

Example

Run the code

Multiline comment in HTML

Multiline comments span multiple lines where the line starts with <-- and ends with -->.

Example

Run the code
HTML Comment