HTML comments are used to document the HTML source code and are not displayed in the browser.
HTML Comment Tag
Comments in HTML are inserted using the HTML comment tag using the following syntax:
<!-- Write your comments here -->
Everything between the
<!-- and the
will be hidden from the display. The HTML comment tag can span several lines but does not support nesting with other HTML comment tags.
Comment tags can be used anywhere on your web page. Typically they should be used where it makes sense in terms of documenting specific parts of the source code wherever needed.
<h1>Chapter 1</h1> <p>This is a paragraph.</p> <!-- Remember to add more chapters here -->
Temporarily Hide Content
HTML comments can be used to temporarily hide content. This can be useful for testing or debugging parts of your source code or content layout.
<p>This is a paragraph.</p> <!-- <p>This is hidden paragraph,</p> <img border="0" src="hidden_image.jpg" alt="Hidden Image"> --> <p>This is a another paragraph.</p>
Hide Inline Content
Comments can be used to hide parts of the content in an HTML page.
<p>This is <!-- text hidden from --> a paragraph.</p>