The Complete HTML Teacher

What To Do With The <Body> Tag





You now know that the <Body> tag is used to tell the web browser that it needs to display the text and graphics, exactly as you have specified. But what else can be done with the body tag?

The <Body> tag is also used to specify the background image or color, the text color, the link color, the visited link color, and the active link color.

Let's start with the easy stuff. Colors. To specify a background color, your body tag would look like this:

<Body bgcolor="blue">

This would cause your background color to be blue.

But we also want to specify a color for our text. Let's make the text black:

<Body bgcolor="blue" text="black">

We want our links to be a different color, so that they will be easy to identify as links for our visitors. Let's make it yellow:

<Body bgcolor="blue" text="black" link="yellow">

Then, we add the color that we want our visited links to be. This will cause the links that the visitor has already clicked on to become a different color than the links he has not visited. It is referred to as the "vlink". Let's make it red:

<Body bgcolor="blue" text="black" link="yellow" vlink="red">

Next, you want to specify what color the link turns when they click on it...The active link, or alink. Let's make it green:

<Body bgcolor="blue" text="black" link="yellow" vlink="red" alink="green">

Now, using these colors and specifications in the body tag, would cause my page to look like this:



Your background is blue, your regular text is black.

Your links will be yellow.

Your visited links will be red. Your active links will be green.


You can choose from the 16 standard Windows colors, which are: Black, white, green, blue, yellow, magenta, cyan, purple, gray, lime, maroon, navy, olive, silver, and teal. However, you can also mix your own colors.

The format for mixing your own colors is #rrggbb. rr,gg, and bb are actually two digit hexadecimal values for the red, green, and blue components of the color. Let's make this easy. There is a color chart located at: http://www.htmlgoodies.com/tutors/colors.html Here, you will find the correct #rrggbb that you want. Now to use this, you would do your body tag like this:

<Body bgcolor="#0000FF">

This would also make your background blue. There are many variations which you can use to create up to 16 million different colors...and there are many places online where you can get the hex codes for those colors. Many HTML editors come with their own color pickers as well.

So, now you know how to add color to the life of your web page...but what if you want to use a background image instead?

No problem. You simply take this tag:

<Body bgcolor="blue" text="Black"link="yellow" vlink="red" alink="green">

And you change it to:

<Body background="yourimage.gif" text="black" link="yellow" vlink="red" alink="green">

Ok, let's not get confused. We changed "bgcolor" to "background". Where we have "yourimage.gif", you would put the file name of the image you wish to use. It may be a .gif or it may be a .jpg. We will discuss these in the Graphics chapter of this e-book. But for now, you need to know that if you are going to use a specific image...a graphic so to speak...for your background, then the correct form of the body tag would be:

<Body Background="nameofyourimage.gif">

If you are using a color for your background, the correct form of the tag is:

<Body bgcolor="yourcolorchoice">

Now, you can get creative with the <Body> Tag to your hearts content. However, when you are deciding colors for your page, please check your choices carefully. You don't want to use colors that don't mix well, or colors that are hard on the eyes. This will cause people to leave your page in a hurry.

You can find good background images online. Check The Graphics Directory for places to look. You should save the images you wish to use into your file that holds your pages.

This isn't so hard...what do I do next?

Contents



Copyright ©1998 by K. Williams Resources. All Rights Reserved