HTML <body> backgroundAttribute
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>
<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
![]()
![]()
![]()
![]()
![]()
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:
|
HTML <body> Tag Other Extensions