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, simply 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 source code of a webpage by end-user. 

Most commonly, there are two types of comment tags used first 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, 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 below line. 

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

1 votes

S

Sunita Verma

The HTML comment tag is used to ignore a piece of HTML code being display on a web page. Commented codes are visible in source code but they are not rendered in the web page.

0 votes

Your Answer