::: Tutorials > HTML

Comments
Keep your code organized with the comment tag


Tutorial by Andrew
Sunday March 30, 2003


The comment tag is one of the most simple to use. It can be used anywhere within your code. It has no attributes to specify or to worry about, and it certainly does not need to have a closing tag.

A typical comment tag looks like this:

What? You don't see anything? The comment tag is not rendered on the web page like the <img src="..."> might. It is simply ignored by web browsers. I'll make it visible for you: <!-- Hello.. this is a comment tag. =) -->

Place this tag anywhere within your HTML document, and all its contents will be hidden from casual viewers. This brings us to its (very important) use. If you ever view the HTML source of websites other than your own, you surely know what a mess they can be. (Try cnet.com for ultimate confusion.) Using the comment tag to clearly show what you mean to do can save headaches for you and for any others who work with you on your web projects.

example:
<HTML>
<HEAD>
<TITLE>blah blah my website blah blah</TITLE>
</HEAD>
<BODY>

<!-- Begin silly poem thing -->
Once upon a time there was a bug.
He lived under a rug.
His friends grabbed his ears,
and gave them a tug.
And now he wishes he had dug... a hole.
<!-- End silly poem thing -->

<!-- Begin column table -->
<TABLE WIDTH=100%>
<TR><TD WIDTH=150> <!-- Begin navigation bar on left -->

<A HREF="/home/">go home</A>
<A HREF="/pictures/">see pictures</A>
<A HREF="/labp/">my web club's website</A>
<A HREF="/links/">links</A>

</TD>
<TD> <!-- Begin main area -->

CONTENT CONTENT CONTENT

</TD>
</TR>
</TABLE>

</BODY>
</HTML>

Just as in application programming, people love you when you comment.


Copyright 2002 BLUEPRINT Los Altos High School Web Club. All rights reserved.
201 Almond Ave. Los Altos, CA 94022