HTML Comments

This lesson is about HTML Comments, how to add comments to your webpage and the importance of comments to your site

Comments in HTML

First let’s define what is a comment?  A comment is a piece or string of code that defines the purpose or to provide information about your code for others to understand your code.

To insert a comment to your webpage, use the comment tag.

 <!--   Your comment here -->

Anything you write between the comment tags will not be displayed in the browser.

 < !--   Your comment here -->

A space between the left angle (<) and the exclamation mark (!) will make your comment invalid, thus the line of code will be shown to the browser.

Importance of comments

Comments are for documentation purposes. Most of us are not fan of placing comments to our webpage but it’s really important that we should practice to place comments to our code not only for your own sake but for others to understand our work.

Note: although comments are for documentation purposes but always remember not to put so much line of comments in your webpage. As we have discussed the comments will not be displayed in the browser but it will consume file size, so it will eventually affect the performance of your webpage.

 Remember: Just write meaningful and useful comments.

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.