html lesson 5

comments

Going back to out first web page we created in html lesson 1 (see the example here), you may have noticed that something in the body of our web page code didn't show up on our web page:

<!-- invisibility rocks!! //-->

We did a bit of sorcery with our line "invisibility rocks!!" by using the "comments" tags "<!--" and "//-->". These tags tell the the browser to ignore anything inbetween them.

In html these days, comments aren't needed that much, but they do become very important later on with more advanced programming so it's a good idea to start practicing leaving comments now while we're in the early stages.

You might want to leave such things in comments as pehaps the date you created the page, some copywrite info, credit or thanks given to anyobody who might have given you some of your code or helped you with it and pehaps thier website address.

But mostly what you want to lave in your comments are instructions. Even if they never intend to share thier code with anybody, a good coder/programmer will leave comments in thier code explaining in plain english what they are trying to do with the code and why.

Write them as if you are writing instructions for somebody else. It may seem silly or pointless at the time, but believe me, a few years down the track when you're taking a look at some old code that you wrote ages ago and you're banging your head on the wall trying to remember and figure out what the heck you we're doing with that code, you'll be wishing you took my advice and wrote comments for yourself.

Trust me, I've been there and it's not pretty when you're trying to decipher 700+ lines of your own ten year old code. Make it a habit and you'll be thanking me one day.


The only place your comments will show up are in the source code.

Click here to move on to the next lesson where you'll find out what the heck that means.



Lesson updated Tuesday 5th August 2008