Versión en español

HTML comment tag

Note: If you don't know what a tag is and/or how you must use it we recommend you to read our HTML tags and attributes tutorial that you can find in our HTML tutorials section.

 

Description

The HTML comment tag is used to insert comments inside the code. All the text inserted inside this tag (<!-- ... -->) will be ignored by the browser (with the exception of scripts and style codes in those browsers that support them) and invisible for the user. It's most common use is to "hide" scripts and style codes from older browsers (without support for it), so they don't show them as plain text.

Note that when writing XHTML code the commented scripts and style codes are completely ignored by the browser.

Attributes

This tag does not have any attribute.


Events

There are no events defined for this tag.

See complete list and information about events in HTML


Examples

A simple comment in the code (the comment is invisible).

Code View
<p>Comment's begin</p>
<!--Here is the comment text-->
<p>Comment's end</p>

Comment's begin

Comment's end


In this case the tag is used to hide a script (in XHTML the script would be completely ignored by the browser).

Code View
<script type="text/javascript">
<!--
function gimme_a()
{
return 'a';
}
-->
</script>

Bypass footer options Send to a friend Send to a friend