HTML Code Comments

HTML comments are an extremely useful feature which can really help keep track of what we are typing. When you are coding HTML it can sometimes be easy to forget what a particular section of code does, particularly when you're working on a very long file, or on several different files.

HTML comments were designed just for this reason - they allow us to enter little snippets of information into the document that will be completely ignored by the web browser. This means they will remain hidden from the user, but we can use them as reminders of what each section of code does.

In order to use a comment you must surround it with the comment opening and closing tags, namely <!-- and -->. Between these tags you can write your comment, like so:

<!-- This is a comment, how helpful -->

Using comments is a very good habit to get into. It may seem tedious and unnecessary at times, but if you ever have to come back and edit a page weeks, months or even years after creating it, you'll be very glad that you included comments to explain what it is all about!