background (HTML attribute)

Spec
Depr. Version
Yes HTML 2
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Full Full Full Full Full

Syntax

background="uri"

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, or aligned to a specific edge of the document); it will simply be repeated along both the x and y axes. Because of this, most web pages to which this technique is applied either display the background as small, repeated images, or use huge images to avoid 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.

Example

This code applies a sandy theme to the page:

<body background="sandy.jpg">
  ⋮
</body>

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

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full

Every browser listed supports this attribute.

User-contributed notes

There are no comments yet.

Related Products