HTML <!--...--> Tag


HTML comments:

<!--This is a comment. Comments are not displayed in the browser-->

<p>This is a paragraph.</p>
Try it yourself »

Definition and Usage

Comment tags are used to insert comments in the source document. Comments are not displayed in the browser.

You can use comments to explain your code, which will help you edit the code at a later time. This is especially useful when the amount of code is large.

You can also store the information customized for the program in the comment content. In this case, this information is invisible to the user, but available to the program. It's a good practice to put comments or style elements in the comment text so that older browsers that don't support scripts or styles display them as plain text.

Browser Support

<!--...--> Yes Yes Yes Yes Yes Yes

Differences Between HTML 4.01 and HTML5


Tips and Notes

You can also use the comment tag to "hide" scripts from browsers without support for scripts (so they don't show them as plain text):

<script type="text/javascript">
function displayMsg() {
    alert("Hello World!")

In addition to having a very obvious role in source documents, many Web servers also use annotations to implement features unique to document server software. These servers can scan documents, find specific character sequences from traditional HTML /XHTML comments, and then take actions based on commands embedded in the comments. These actions may be simply including text in other files (so-called server-inside include), or they may be complicated to execute other commands to dynamically generate the content of the document.