<!--...-->


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

Example

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>php中文网(php.cn)</title>
</head>
<body>

<!--这是一个注释,注释在浏览器中不会显示-->

<p>这是一个段落</p>

</body>
</html>

Run instance»

Click the "Run instance" button to view the online instance


Browser support

Internet Explorer

# #All major browsers support the <!--...--> comment tag.


Tag definition and usage instructions

<!--...--> The comment tag is used to insert comments in the source document. Comments will not be 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 customized information for the program in the comment content. In this case, the information is invisible to the user, but available to the program. A good practice is to put comments or style elements within the comment text to prevent older browsers that don't support scripts or styles from displaying them as plain text.

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

Comment: The last two forward slashes in the command line (/ /) is the JavaScript comment symbol. This ensures that JavaScript will not execute the --> tag.

In addition to their obvious role in source documents, many web servers also use comments to implement features unique to document server software. These servers can scan documents to find specific sequences of characters within traditional HTML/XHTML comments and then take appropriate actions based on commands embedded in the comments. These actions may be as simple as including text from other files (so-called server-inside include), or as complex as executing other commands to dynamically generate the content of the document.


Differences between HTML 4.01 and HTML5

None.


Standard Properties

<!--...--> Annotation tags do not support any standard properties.

For more information about HTML standard attributes, visit Standard Attributes.


Event Properties

<!--...--> Annotation tags do not support any event properties.

For more information about HTML event properties, visit Event Properties.