English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML reference manual

HTML tag大全

HTML: <body> background attribute

This article introduces the usage of the HTML body background attribute, including online examples demonstrating how to use the HTML body background attribute, browser compatibility, syntax definition, and detailed information about its attribute values.

 HTML <body> tag

Online Example

Specify a background image for the document:

<!DOCTYPE html>
<html>
<head>
<title>HTML:<body> background attribute - basic tutorial website oldtoolbag.com</title>
<body background="/static/images/bgimage.gif">
<h1>Hello world!/h1>
<p><a href="https://www.oldtoolbag.com">Visit the basic tutorial website!/a></p>
</body>
</html>
Test to see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All mainstream browsers support the background attribute.

Definition and Usage

HTML5 The background attribute of <body> is no longer supported. Please use CSS instead.

The background attribute of <body> in HTML 401 The feature has been deprecated.

The background attribute specifies the background image of the document.

Compatibility Comments

In HTML 401 It is not recommended to use the background attribute of the body element; in XHTML 1In HTML 4.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 about background-image attributeknowledge.

Syntax

<body background="URL">

Attribute Value

ValueDescription
URL

URL of the background image. Possible values:

  • Absolute URL - Points to another site (for example href="http://www.example.com/bgimage.gif")

  • Relative URL - Points to a file within the site (href="bgimage.gif")

 HTML <body> tag