Learning HTML
Chapter 5 - Using Graphics and Colors

5.5 Colors and Backgrounds

It is possible to use graphics images to create a background for your web document. For example, here is an image file called sealbg.gif, 210 pixels wide by 350 high, which looks like this:

To use it as a background, the <BODY> tag must be placed at the beginning of your document (see Chapter 3 for details). The format for this tag is:

 <BODY BACKGROUND="sealbg.gif">

The image is then repeated throughout the document. Take a look at a sample document to see how it works.

Try to avoid using dark or complex images for your background. Some images can make it extremely difficult to read your text.

The <BODY> tag may also be used to change the colors in your document. Using the BGCOLOR parameter lets you specify the background color of your document. The following, for example, makes the background white:

 <BODY BGCOLOR="#FFFFFF">

A variety of colors can be created using different codes. Here are a few examples:

FF00FF FFFF00 00FF00 00FFFF 0000FF

Note: these examples use hexadecimal codes to specify colors. This was required by older browsers. Many newer browsers support color names, including : Aqua, Blue, Green, Lime, Navy, Silver, Teal, White, Yellow. The format for this would be:

 <BODY BGCOLOR="Blue">

Different colors may also be assigned to your text and your links using the <BODY> tag:

 <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#003399">

Here's a sample document showing how it works.

Try changing the colors on one of the pages you've created. Open the file second.html using Notepad and add a <BODY> tag after the </HEAD> tag. Use BGCOLOR="Aqua" and TEXT="Blue" to change colors. Then save the file and view it in Netscape to see the changes.

At the beginning of this part, you were warned about overusing images. The same warning applies to colors. Be careful about using these features. The results can vary depending on the type of browser (and type of computer) your viewers use. What looks great on your computer can be an unreadable mess on someone else's. Do not use background colors and images which are so dark that they make it hard to read the text.


Learning HTML
www.dickinson.edu/~dempsey
Last updated 6/8/2001
Copyright © 2001 Paul Dempsey