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 ? Will the browser ignore what I wrote after ?