Advertisement

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

Examples

HTML comments:

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

<p>这是一段普通的段落。</p>

Try it yourself

Browser Support

IE Firefox Chrome Safari Opera

All browsers support comment tags.

Definition and Usage

Comment tags are used to insert comments in the source code. 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. Especially useful when you write a lot of code.

Use comment tags to hide browser does not support script is also a good habit (so that no script will be displayed as plain text):

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

Note: The comment line at the end of two slashes (//) is the JavaScript comment symbol. This prevents JavaScript Execution -> tag.

Differences between HTML 4.01 and HTML5

no.

Standard property

Any comment tags do not support the standard attributes.

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

Event Properties

Any event attribute comment tags are not supported.

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