\"Writing.Com
*Magnify*
SPONSORED LINKS
Printed from https://shop.writing.com/main/books/entry_id/1066824-HTML-Comments
Image Protector
\"Reading Printer Friendly Page Tell A Friend
No ratings.
by GERVIC Author IconMail Icon
Rated: E · Book · How-To/Advice · #2311504
Your made-easy guide to create a webpage.
#1066824 added March 24, 2024 at 5:58am
Restrictions: None
HTML Comments
HTML Comments
         
HTML comments are not displayed in the browser, but they can help document your HTML source code.




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


<!-- Write your comments here -->


         
Notice that there is an exclamation point (!) in the start tag, but not in the end tag. This works similarly with Writing.Com's WritingML {--comment here--} tag. Visit "Note: Introducing the WritingML "Comments" ..." for details about WritingML "Comments".


IMPORTANT: Comments are not displayed by the browser, but they can help document your HTML source code.



Add Comments
         
With comments you can place notifications and reminders in your HTML code.


Example:
<!-- This is a comment -->

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

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


yields:

This is a paragraph.




Hide Content
Comments can be used to hide content. This can be helpful if you hide content temporarily. This works similarly with Writing.Com's WritingML {hide} ... {/hide} tag.

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

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

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


yields:

This is a paragraph.

This is a paragraph too.



You can also hide more than one line. Everything between the <!-- and the --> will be hidden from the display.

Example:
<p>This is a paragraph.</p>
<!--
<p>Look at this cool image:</p>
<img src="https://www.writing.com/main/images/action/display/ver/1650359756/item_id/2271610.png" alt="Reviewer of the Month">
-->
<p>This is a paragraph too.</p>


yields:

This is a paragraph.

This is a paragraph too.


         
Comments are also great for debugging HTML, because you can comment out HTML lines of code, one at a time, to search for errors.




Hide Inline Content
         
Comments can be used to hide parts in the middle of the HTML code or hide a part of a paragraph.


Example:
<p>This <!-- great text --> is a paragraph.</p>

yields:

This is a paragraph.
© Copyright 2024 GERVIC (UN: gervic at Writing.Com). All rights reserved.
GERVIC has granted Writing.Com, its affiliates and its syndicates non-exclusive rights to display this work.
Printed from https://shop.writing.com/main/books/entry_id/1066824-HTML-Comments