background (HTML attribute)
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
| IE | 5.5 | Full |
|---|---|---|
| 6.0 | Full | |
| 7.0 | Full | |
| Firefox | 1.0 | Full |
| 1.5 | Full | |
| 2.0 | Full | |
| Safari | 1.3 | Full |
| 2.0 | Full | |
| 3.0 | Full | |
| Opera | 9.2 | Full |
| 9.5 | Full |
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.

