HTML <body> backgroundAttribute

HTML body 标签参考手册HTML <body> Tag

Example

Specifies a background image for the document:

<html>
<body background="bg.gif">
<h1>Hello world!</h1>
<p><a href="../index.html">Visit Rookie Tutorial!</a></p>
</body>
</html>

Try it yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the background attribute.


Definition and Usage

HTML5 no longer supports the <body> background attribute. Please use CSS instead.

The background attribute of <body> is deprecated in HTML 4.01.

The background attribute specifies the background image of the document.


Compatibility Notes

In HTML 4.01, the background attribute of the body element is deprecated; in XHTML 1.0 Strict DTD, the background attribute of the body element is not supported. Please use CSS instead.

CSS Syntax: <body style="background-image:url(bgimage.jpg)">

CSS Example: Add a background image to the document

In our CSS tutorial, you can find more aboutthe background-image attribute.


Syntax

<body background="URL">

Attribute Values

Value Description
URL

The URL of the background image. Possible values:

  • Absolute URL - points to another site (e.g. href="http://www.example.com/bgimage.gif")
  • Relative URL - points to a file within the site (href="bgimage.gif.html")


HTML body 标签参考手册HTML <body> Tag Other Extensions