1. Home
  2. Computing & Technology
  3. Web Design / HTML

How can I specify background images?

By Jennifer Kyrnin, About.com

Question: How can I specify background images?

Answer:

The most common method of setting a background image is in the body tag, using the "background" attribute. Like using any other image, simply set the URL in the value of the background attribute.

<body background="URL of background image">

However, this method has been deprecated (removed from the specification) as of HTML 4.0 and XHTML 1.0. Now, in order to set a background image, you should use Cascading Style Sheets.

<style>
<!--
  body {
    background : URL of background image;
  }
-->
</style>

There are several things you should be aware of when using the background attribute:

  • make sure you have uploaded your image
  • verify the URL of the image, by testing it separately before you put your page live
  • use images that tile effectively
    tiling is the effect of the image repeated across the browser screen, both horizontally and vertically
  • if you decide to use a large image (to prevent tiling) make sure that the file size is not overwhelmingly large - large images will affect the download time

Help with Cascading Style Sheets
More on the body tag
Uploading images

More Web Design / HTML Q&A

Explore Web Design / HTML

More from About.com

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. About.com Web Design A to Z
  5. FAQs
  6. How can I specify background images?

©2008 About.com, a part of The New York Times Company.

All rights reserved.