Latest web development tutorials

HTML body background property

HTML body tag Reference Manual HTML <body> tag

Examples

The document specifies a background image:

<html>
<body background="bg.gif">
<h1>Hello world!</h1>
<p><a href="http://www.w3big.com">访问本教程!</a></p>
</body>
</html>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support background attributes.


Definition and Usage

HTML5 is no longer supported <body> background attributes. Use CSS instead.

<Body> The background attribute is deprecated in HTML 4.01.

background attribute specifies a background image specified document.


Compatibility Notes

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

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

CSS Example: Add a background image to a document

In our CSS tutorial you can find more information about the background-image property knowledge.


grammar

<body background="URL">

Property Value

value description
URL

URL of the background image. Possible values:

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


HTML body tag Reference Manual HTML <body> tag