Latest web development tutorials

HTML <-! ... -> Comment tags

Examples

HTML comments:

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

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

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support <! --...--> Comment tags.


Tag definitions and instructions

<! --...--> Comment tag is used to insert comments in the source document. Comments are not displayed in the browser.

You can use comments to explain your code, it helps you edit the code at a later time. Under particularly large amount of code it is useful.

You can also customize the program for the information stored in the comment. In this case, the information is not visible to the user, but the program is available. A good habit is to comment or style elements into the comment text, so you can avoid not support scripting or style older browsers display them as plain text.

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

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

In addition to a very significant role in the source document, many Web servers also use comments to implement the document server software-specific features. These servers can scan a document and find specific sequence of characters from the traditional HTML / XHTML comment, and then take appropriate action based on comments embedded in the command. These actions may include additional files are simple text (the so-called server-side includes, server-inside include), it may be complicated to execute other commands to dynamically generate the content of the document.


Differences between HTML 4.01 and HTML5

no.


Standard property

<! --...--> Comment tag does not support any standard attributes.

For more information about the HTML standard attributes, visit the standard attributes .


Event Properties

<! --...--> Comment tag does not support any event attributes.

For more information about the HTML event attributes, please visit the event property .