Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML body background attribute

HTML background attribute

HTML body Tag Reference HTML Tag

Example

Specify a background image for the document:

Hello world!

Visit Runoob Tutorial!

Try it »


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the background attribute.


Definition and Usage

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

The background attribute was 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:

CSS example: add a background image to the document

In our CSS tutorial, you can find more details about background-image attributeknowledge.


Syntax

  • 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 Reference HTML tag