How often should I leave comments within my code?


#1

Question

How often should I leave comments within my code?

Answer

A good rule of thumb here is to leave comments for any piece of code that might be non-obvious to yourself or anyone who might be reading your code.

If you are working on a team, you want to ensure that your team members can understand your code. If you are working on an open source project, you want to ensure the wider development community can understand your code. If you are working on a solo project, you want to ensure that your future self can understand your code.

As far as workflow is concerned, it is not uncommon to leave comments both as you code and after you have written some code.


FAQ: Learn HTML Elements - Common HTML Elements - Comments
#2

Can I make comments after the </html>? Will the browser ignore what I wrote after </html>?


#3

A very late reply, but it bears mention that anything outside of <html></html> will not be regarded as HTML, so the comment (with tags) MAY render to the display, which is not something we would want. Nothing should ever be written outside of the root element.