On this page, you'll find:
HTML for Background Images
Add A Background - Step by Step Instructions
Adding a Background Color
Adding Background, Text and Link Colors Step by Step
Some Things To Experiment With
Troubleshooting Problems With Backgrounds

HTML for Background Images

If you want to use a background tile to add a background image to your web page, you will want to modify the BODY tag. <BODY BACKGROUND="filename.gif"> This tag should go after the close of the </TITLE> tag. The beginning of an HTML document with a background tile would look like this:
<HTML>
<HEAD>
<TITLE>
Your Web Page Title
</TITLE>
</HEAD>
<BODY BACKGROUND="filename.gif">

Add A Background - Step by Step Instructions

You will need the web page you saved from the first tutorial, and an image to use as a background. You can create your own web page backgrounds, or download backgrounds from various graphic archives. You can also download the image to the left by clicking your right mouse button (Mac users click-and-hold) until you see a menu. Select Save Image As to download this background for use in your example. Download it to the same folder that you saved your HTML file to.

For this example, let's suppose that your background is named back.gif. Open your HTML file in your text editor, and change the BODY tag to read:
<BODY BACKGROUND="back.gif">

Then save your file. You can compare your page to the cheat sheet for this tutorial, and see what the example looks like using the background image. Upload your file, and upload the graphic to the same folder (or directory) on your web server as the HTML file.

Important! Your file names must always be spelled exactly the same in your HTML file as they appear for the filename. File names are case sensitve in HTML! A file named BACK.GIF will not load in the web browser if the HTML file refers to it as back.gif, Back.gif, or back.jpg

Adding a Background Color

You can specify a background color by using a hexcode, or numerical value that the browser displays as a color. We have a healthy hexcode color chart for reference, or you can download several useful color utilities from Tucows (browse the HTML Color Utilities section). Most HTML editors also include a utility for

Okay, so you've found a wonderful background color for your web page. You can also specify hexcode colors for your text, links, visited links, active links. And (isn't HTML cool!) you can specify both a background gif and a background color. This gives folks something to look at while your background gif loads.

Adding Background, Text and Link Colors Step by Step


What's the HTML look like for adding hexcodes for the background, text, and links? Open up your example HTML page again, and edit the BODY tag:

<BODY BACKGROUND="back.gif" BGCOLOR="#FFCC99" TEXT="#000080" LINK="#FF0000" VLINK="#800000" ALINK="#800080">

BGCOLOR is the tag for background color, TEXT specifies a text color, Link is for links on a page, VLINK is for links that have been visited, and ALINK is for active links. The example page doesn't have any links, so these won't be visible on this particular page.

You can view the cheat sheet and the example for this tutorial.

The main thing to remember is that you want to have a lot of contrast between your background color and text, so that the text is legible.

Some Things To Experiment With

Now that you understand how to create hexcodes and add backgrounds, try experimenting with different color combinations. Try creating a page that uses only shades of a single color, like blue. Try creating a holiday page using hexcode colors. Using the same page, create a "warm" version and a "cool" version, using hexcodes. Warm colors are reds, browns, oranges, and yellows. Cool colors are blues, grays, purples, and greens.

Troubleshooting Problems With Backgrounds

If you're having trouble with your background or text colors, here are some things to check:
  • Make sure the BODY tag comes after the closing HEAD tag in your HTML file.
  • Make sure you've saved your HTML file in the correct format.
  • Make sure you've uploaded your graphic to the same folder/directory as your HTML file
  • Make sure your background graphic is in GIF or JPG format. Although Microsoft Interent Explorer does support BMP format graphics, Netscape does not. BMP is a bad format for web graphics anyways: the files are much larger than the same file would be as a GIF or JPG.
  • Make sure that the tags that use quotations have both sets of quotes in every instance - <BODY BACKGROUND="back.gif" BGCOLOR="#FFCC99" TEXT="#000080" LINK="#FF0000" VLINK="#800000" ALINK="#800080"> Missing just one quotation can prevent part of the page from loading.
  • If your HTML is correct, and your graphic is uploaded, but you still can't see the background image, try opening the graphic in a paint program like Paint Shop Pro, and make sure the file will open and is visible. If the file won't open, it could be corrupted. Try another graphic.

Create Your Own Web Adventure with the Web Diner!

Tutorials | Home | Glossary

All content copyright of Web Diner Inc., 2000. Do not redistribute or repost this content.