- Web Development Tutorials

Adding HTML Comments

Using comments in your HTML code
Comments can be a nice way to help yourself when you are coding your Web page. Comments are invisible to a Web browser when it displays your Web page. The only way to view comments is to look at the source (HTML) code of the Web page. In this way, you can leave yourself notes so that you don't forget something when you come back later to redesign the page. So, how is it done? To write a comment, you begin with a less than sign (<) followed directly by an exclamation point (!) and two dashes (--). After this, you type in your comments. To end the comment, you use two dashes (--) followed directly by a greater than sign (>).

<!-- I am a comment. I feel invisible though. -->

You can comment on multiple lines, just be sure you remember to end the comment!

You can't see me....
unless you look at the page source code.

To look at something more useful, you could use a comment to remind yourself that a section of code is supposed to perform a certain task:

<!-- This image should be aligned to the right, and have alt text -->
<img src="mypet.gif" align="right" alt="Look at my Kitty Cat!" />

Of course, you do not need to have a kitty cat to qualify!

Well, that does it for comments. So, let's move on to the next section: Using HTML Lists.

Copyright © The Web Design Resource. All rights reserved. | Contact Us | Privacy Policy