HTML Comment Tag

HTML Comment Tag

The HTML comment tag is used to write comments in main code file. The comments that we write are not displayed on the browser like other HTML content. It is only for programmers.

How to write HTML Comment Tag

To write comment using HTML Comment Tag is very simple, below is the example.

<!DOCTYPE html>
<html>
<body>
<!--I am a comment. I live inside HTML Comment Tag.
Read me to know about this code. This piece of code 
is about HTML Comment Tags.-->
</body>
</html>

HTML Comment Tag Usage

Comments are very helpful and it's always suggested to write comments in your code. Comments can tell you about the purpose of a particular piece of code which can help you when you edit the code in future.

Comments act as Note to any programmer who reads it or works on it. Comment tag is used to explain your code.

You can use HTML comment tag to hide or comment out the scripts and your browser won't notice it.

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
<!--
function displayMsg() {
  alert("This Script won't be executed")
}
//-->
</script>
</body>
</html>

Note: HTML Comment Tag doesn't support standard or event attributes.

HTML Comment Tag Video

Watch our video on comment tag and subscribe our Youtube Channel.

HTML Comment Tag HTML Doctype Tag HTML anchor Tag HTML abbr Tag HTML acronym Tag HTML address Tag HTML applet Tag HTML area Tag HTML article Tag HTML aside Tag HTML audio Tag HTML b Tag HTML base Tag HTML basefont Tag HTML bdi Tag HTML bdo Tag HTML big Tag HTML blockquote Tag HTML body Tag HTML br Tag HTML Button Tag HTML Canvas Tag HTML Caption Tag HTML Center Tag HTML Cite Tag HTML Code Tag HTML Col Tag HTML colgroup Tag HTML data Tag HTML datalist Tag HTML dd Tag HTML del Tag HTML details Tag HTML dfn Tag HTML dialog Tag HTML dir Tag HTML div Tag HTML dl Tag HTML dt Tag HTML em Tag HTML embed Tag HTML fieldset Tag HTML figcaption Tag HTML figure Tag HTML font Tag HTML footer Tag HTML form Tag HTML frame Tag HTML frameset Tag HTML Heading Tags HTML head Tag HTML header Tag HTML hr Tag HTML html Tag HTML i Tag HTML iframe Tag