- Web Development Tutorials

Using a Background Image

How to add a background image to your page
Note: These effects can now all be achieved using Cascading Style Sheets.

To add a background image to your page, you will need to locate the <body> tag in your document. When you have found it, you may see just the word body, or you may see a string of commands afterward. It may look something like this:

<body bgcolor="#FFFFFF" text="#000000">

What we are going to do is add a command after the word body. So, go to the end of the word body, skip a space, and type the following:


Now your body tag should look something like this (and may have more commands):

<body background="">

Now, we are going to place the url of the image inside the quotation marks. So, if the image I want to use is at, I would insert this into the command, like this:

<body background="">

Your image should have the file extension .gif or .jpg . If not, you will want to covert it to one of these file types. One program that will do this is Paint Shop Pro, which is available as shareware from JASC.

Now, if your image file is located in the same directory as your HTML file, you can just type the filename of the image rather than the full url. So, if we want image2.gif to be the background image, and it is in the same directory as the page we are editing, we can type the command this way:

<body background="image2.gif">

Now, as a real example, I will use an image from my server as a background on a page. The name of the image is "next.jpg". The url for the image is So, to use this as a background, I would type in this:

<body background="">

Now, if I put an HTML file in my "images" directory, I could use the image by typing in just the filename, like this:

<body background="next.jpg">

Okay, now you can use your own image as a background... so put a picture of yourself as a background. That's always kind of fun...

Well then, let's move on to the next section, Resizing Images.

Copyright © The Web Design Resource. All rights reserved. | Contact Us | Privacy Policy