Description
HTML Comment tag <!-- -->
is used to insert comments within the HTML markup.
HTML Comments can be used for many purposes and here are some of them.
- Source code documentation
- Reminders for future changes or enhancements
- Hide content temporarily while development testing
Syntax
<!-- Comment content goes here -->
Examples
Single line comment, where the comment is on a single line.
<!-- Single line comment content goes here -->
Multi-line comment, where the comment extends to multiple lines.
<!--
Comments line 1
Comments line 2
Comments line 3
-->
Inline comment, where the comment is within other element's content.
<p>This paragraph <!-- Inline comment --> has an inline comment.</p>
Attributes
The following table shows the list of supported and unsupported attributes for the tag <!-- -->
used for comments.
Attribute Type | Details |
Tag-Specific Attributes | The tag <!-- --> does not have any tag-specific attributes. |
Global Attributes | It doesn't support any HTML Global Attributes. |
Event Attributes | It doesn't support any HTML Event Attributes. |
Browser Compatibility
HTML Comment <!-- ... -->
is supported in most modern browsers.
- Google Chrome 1+
- Internet Explorer or Edge 2+
- Firefox 1+
- Apple Safari 1+
- Opera 4+