Skip to main content

HTML Comments

HTML comments are not visible in browsers, although they can aid in the documentation of your HTML source code.

HTML Comment Tag

You can add comments to your HTML source by using the following syntax:

<!-- Write your comments here -->

You'll see that the start tag has an exclamation point (!) while the end tag does not.

Add a Comment

You may add reminders and notifications using comments in your HTML code:

<!-- This is a comment -->

<p>This is a paragraph.</p>

<!-- Remember to add more information here -->

Hide Content

Content can be hidden using comments.

It may be useful if you temporarily conceal content:

<p>This is a paragraph.</p>

<!-- <p>This is another paragraph </p> -->

<p>This is a paragraph too.</p>

You can also hide more than one line, everything between the will be hidden from the display.

<p>This is a paragraph.</p>
<!--
<p>Look at this cool image:</p>
<img border="0" src="pic_trulli.jpg" alt="Trulli">
-->
<p>This is a paragraph too.</p>
tip

Comments are also useful for debugging HTML since they allow you to look for mistakes by commenting out HTML lines of code one at a time.

Hide Inline Content

Comments can be used to conceal sections of HTML code in the middle.

<p>
This
<!-- great text -->
is a paragraph.
</p>
Example
<p>This is a paragraph.</p>
<!--
<p>Look at this cool image:</p>
<img border="0" src="pic_trulli.jpg" alt="Trulli">
-->
<p>
This is a
<!-- great text -->
paragraph too.
</p>
Loading...