Why we use <!--this is a comment-->? And what the benefit from tis tag? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why we use <!--this is a comment-->? And what the benefit from tis tag?

25th Jul 2017, 6:52 PM
Mohamed
Mohamed - avatar
8 Answers
+ 4
Comments are good to read codes for you and other people.
25th Jul 2017, 6:55 PM
Chocolatte
Chocolatte - avatar
+ 11
<!-- commenting used to explain your code which can help you edit the code later ! they are useful if you have lot lines of code -->
25th Jul 2017, 6:59 PM
Prudhvi Raaj
Prudhvi Raaj - avatar
+ 6
it doesn't really help the browser, but moreso you and the person who is reading it
25th Jul 2017, 7:06 PM
esenia
esenia - avatar
+ 5
there is no benefit for the browser but if you have multiple people making the website or you leave it for a few months and then come back it will happen you know what does what
25th Jul 2017, 6:59 PM
Cheesy Game Studios
Cheesy Game Studios - avatar
+ 4
i use the comment tag to leave notes, instructions to other people when making a code. its not necessarily mandatory to use it but it makes the code a bit easier to read. also, you can leave notes before and after a line of code. it makes it easier to put together as well
25th Jul 2017, 7:05 PM
esenia
esenia - avatar
+ 2
If you forget what a determinate code does comment can help you
25th Jul 2017, 7:01 PM
Chocolatte
Chocolatte - avatar
+ 1
for the browser
25th Jul 2017, 6:56 PM
Mohamed
Mohamed - avatar
+ 1
I'll amend to the answers, but when I'm testing locally, and cannot be bothered to use PHP, etc. at that time, using <!-- --> can allow me to comment out HTML which I am unfinished with, or I need to debug something else for CSS / Javascript. EDIT 2018/09/19 PDT: It also allows me to comment out incomplete `<script>` tags (to prevent errors), or otherwise help isolate a bug when it comes down to which `<script>` is the cause.
30th Jul 2018, 6:40 PM
Katie (Ctrl-Alt-Cuteness)
Katie (Ctrl-Alt-Cuteness) - avatar