Skip to: content, navigation

by Ian Lloyd

background (HTML attribute)

Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full
Spec
Depr. Version
Yes HTML 2
background="URL of background image"

Example

This code applies a sandy theme to the page:

<body background="sandy.jpg">

Description

The background attribute is used to display a background image on the web page. It’s not possible to specify how the image is to be displayed (for example, you can’t specify it to be centered, non-repeating, aligned to a specific edge), but will simply be repeated along both the x and y axis. Because of this, most web pages to which this technique is applied either display the background as small, repeated images; huge images must be used to avoid this kind of tiling repetition.

This attribute is now deprecated. Background images should instead be specified using the CSS background or background-image properties. These offer far more flexibility, allowing the author to define whether the image should be repeated on the x or y axis, along both axes, or not at all; it’s also possible to position the image relative to any of the document’s edges.

Value

This attribute takes as its value the location of the image relative to the referencing document, relative to the server root, or as a complete URI containing the http:// protocol, the server name, and the path to the document on that server.

Compatibility

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

Every browser listed supports this attribute.

User-contributed notes

There are no comments yet.

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters