Comments in HTML code are important. HTML Commenting is very much recommended as if you come back to your HTML code in the future you will be able to tell what each part of your HTML Code is doing - The better commented it is, the easier it will be for you to pick up again.

HTML Comments are not displayed in the users web browser. Therefore the user is not able to view the comments, unless they view the page source.

Commenting within a Development team.

It is also advisable to use comments when working in any development team, as then any member of your team will hopefully be able to see what HTML you’ve developed, and what each part of the HTML on the web page is displaying.

Also if you’re on holiday it’s helpful too!

How do I place HTML comments in my code?

To place HTML Comments in your code all you have to do is place <!— Which is the opening tag, and --> which is the closing tag, around any piece of HTML to make it into a comment.

<html>
  <body>
    <p>I am not commented out, so I can be seen by everyone!</p>
    <!--<p>I am a commented out piece of code, therefore the user will not be able to see me.</p>-->
  </body>
</html>

Something to note is that you can even place comments around other tags to ‘comment out’ the tag. Ie. You can place it around an image to comment out the image from the page. Commenting out an image

Example of Commenting out an image:

<html>
  <body>
    <img src="/images/stories/tryit2.jpg" alt="Try It Image" />
    <p>This image is NOT commented out, so it can be seen by everyone!</p>
    <!--<img src="/images/stories/tryit2.jpg" alt="Try It Image" />-->
    <p>This image is commented out, therefore the user will not be able to see it.</p>
  </body>
</html>