WengerEnterprises
    Simplifying Web Design


Pages

Tools

Webmasters


    

Comments



The first thing we need to do to learn comments is to create a page.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>My Webpage</title>
</head>
<body>
<p>Hi</p>
</body>
</html>

You should understand everything there. If you don't, go back a few lessons. Now this lesson is on comments. I don't consider this as a tag really, but you can consider it one if it helps you. A comment is different from a tag or the doctype. It doesn't do anything you can see. In fact, it makes it so you cannot see things.

Here is an example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>My Webpage</title>
</head>
<body>
<p>Hi</p>
<!-- Hey, this is a comment, can't see me! -->
</body>
</html>

That comment is very useful, but you should get the general idea. I will use one right here... did you see it? That's the point of a comment - to hide things. Now you may be thinking why you would want to hide things. Think if you're working on highly advanced stuff and you don't know what does what. You won't know what to edit without a little help. That's where a comment comes in. You can add a comment stating what you're doing where, how it works, or just notes to self. Another great thing with comments is that you can "comment out" parts of a page you don't need, but might need later. The hidden comment where it was said "I will use one right here... did you see it?" is demonstrated below.

I will use one right here... <!-- hi --> did you see it?

Now what if you wanted to get rid of that paragraph that says "Hi" on that sample page, here's what you do:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>My Webpage</title>
</head>
<body>
<!-- <p>Hi</p> -->
<!-- Hey, this is a comment, can't see me! Haha. -->
</body>
</html>

Now if you loaded that page, you would see that the "Hi" isn't there. This is much more important when you get into more complicated things. For example, if you are finishing a page and discover a problem with it, you can just comment out portions that you think may be the problem until you can figure out the general area where you're going wrong.

In future lessons I will be using comments to help you understand the lesson, so remember the syntax (structure of a language) of a comment. The next lesson will be on formatting text.




©WengerEnterprises.com - All Rights Reserved

Privacy Policy