TOP CATEGORIES

×

What is the HTML comments tag?

A

Alka Patel

HTML Comment Tag

The HTML comment is used to ignore a piece of HTML code being rendered in a web browser. If you want to hide some HTML content, then you can comment on that content, but note that this is not a way to hide something secret because commented HTML content can be seen in the source code of a webpage by an end-user. 

Most commonly, there are two types of comment tags used in page coding: a single-line comment <comment> tag and a multiple-line comment <!-- ..... --> tag to hide code.

<comment> Tag 

  • The <comment> tag is supported by only a few browsers, like IE. It is not recommended to use it, so try not to use the <comment> tag.
  • <comment> The tag has both opening and closing tags, see example below.
  • <comment><p>This paragraph is commented</p></comment>

<!-- ... --> Tag 

This <!-- ... --> is most widely used and supported by web browsers; it is very easy to use, just type all HTML content between <!-- opening and --> closing tags, like the line below. 

  • <!-- content here -->
  • <!-- <p>This paragraph is commented</p> -->

1 votes

S

Sunita Verma

The HTML comment tag is used to exclude certain HTML code from being displayed on a web page. While commented code is visible in the source code, it does not appear in the rendered web page.

0 votes

Your Answer