HTML <!--...--> tag
- Previous Page Keyboard Shortcuts
- Next Page <!DOCTYPE>
Definition and Usage
Comment tags are used to insert comments in source code. Comments will not be displayed in the browser.
You can use comments to explain your code, which can help you during future source code editing. It is especially useful if you have a large amount of code.
Example
A HTML comment:
<!-- This is a comment. Comments are not displayed in the browser. --> <p>This is a paragraph.</p>
Tips and Comments
You can use comment tags to 'hide' scripts so that browsers that do not support scripts will not display them as plain text:
<script type="text/javascript"> <!-- function displayMsg() { alert("Hello World!") } //--> </script>
Note:The double forward slashes (//) at the end of a comment line are JavaScript comment symbols. This can prevent JavaScript from executing the --> tag.
Global Attributes
Comment tags do not support any global attributes.
AboutGlobal Attributesfor more information.
Event Attributes
Comment tags do not support any event attributes.
AboutEvent Attributesfor more information.
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Previous Page Keyboard Shortcuts
- Next Page <!DOCTYPE>