Conquer HTML Ep[5]: Adding Comments

You are currently viewing Conquer HTML Ep[5]: Adding                          Comments

What are comments?

Suppose you code a website today and go on a long vacation. There are chances that when you return to developing your website, you would have forgotten what operations a certain piece of code performs. This is where comments come to the rescue.

We use comments to write some reminders in the code so that we know what it does. It is also recommended to write comments when multiple people are working on the same project so that everyone knows what operation each code contribution is performing.

Comments do not have any effect on the working or appearance of the website; they are written only for better code understanding.

How to write comments in HTML?

HTML comments start with <!– and end with –> 


<!-- This is a comment that says below line is a heading --> 
<h1> Heading </h1>
Comments can be of multiple lines, 
just enclose them inside the <!-- -->

How to write good comments?

  1. Comments should be written clearly so that they are distinctly visible while scrolling.
  2. You should not write comments before each and every line, write comments only where it is necessary.
  3. Comments should be in the language that all all the developers in the team know.

A code base with proper well explained comments is called a well-documented code. 

Using comments for testing your code:

Did you know, you could use comments to test or debug your code! Comments do not affect the working or appearance of a website, so if your website is not working as expected, you can try commenting out a piece of code and see if it starts working. Commenting a code basically removes that part of code from the compilation or interpretation, which is very useful for debugging.

Arpit Pandey

Hey there! I am Arpit Pandey, a full stack web developer, SEO specialist, C++ programmer and Co-Founder of this blog. I love to code and write articles!

Leave a Reply