What is the use of comment tag?

I just ran through entire html section and I am I am going back to it to actually understand how things are actually working.
So I’m on comment tag section. So basically when you put a comment tag, the section that has comment tag will not be displayed on browser and I just don’t see the purpose of it and it does not really explain the purpose of comment tag in training section. I know this sounds like a ridiculous question but I would greatly appreciate if members can explain the purpose of comment tag

thank you everyone

1 Like

Comments are mainly there for fellow developer / yourselves from the future.

In general you either want comment for something visual (for example some separator in a long file)
Or to explain reasoning of something to a potential reader.
So even if the client would not benefit from them, a fellow developer or yourself will.

They are mainly annotations, the same way you may take notes on a book or a paper about something that you find valuable.

Hope it helps.

1 Like

Comment is extremely important especially for programmers (both game and web programmers). Comment tag usually use to “caption” your code and when you have a bug or something in your website or game, you can easily find it to fix. I have an example like this:

You coded a lot for your personal website.
You are coding your info part and that part has a lot of codes.
Suddenly, your website got a problem about your picture.
You want to fix some codes at the picture part.
But you didn’t use the comment tag, now you have to find your code about your picture in thousand of code lines.
If you already use the comment tag, you easily find it and fix it

Comments are used for documentation and explanations as has already been explained. Comments are sometimes used to temporarily remove code. If you need to remove something but you are not sure whether you will need it then you can make the code a comment and then if you decide you need it then it is very easy to uncomment the code.

Thank you so much. This totally makes sense now. I really appreciate your comment :slight_smile:

This is really great examples. This really helped to me understand the importance of comment tag. thank you so much

You are right and now i get it why comment tag is very important in programming. thank you so much for you answer. I really appreciate it

Use comment to explain your code

It’s nice to hear that you understand now. Happy coding and looking forward to see your project

Vào Th 3, 29 thg 6, 2021 lúc 2:31 CH James Lim via The freeCodeCamp Forum <freecodecamp@discoursemail.com> đã viết:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.