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

HTML DOM Style backgroundImage property

Style backgroundImage property

Style Object Reference The Style object


Definition and Usage

The backgroundImage property sets or returns the background image of an element.

Syntax

Set the backgroundImage property:

Object.style.backgroundImage="url('

URL

')|none|inherit"

Return the backgroundImage property:

Object.style.backgroundImage

Value Description
url('URL') The location of the image file.
none Default. No background image.
inherit The background-image property is inherited from the parent element.

Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the backgroundImage property.

**Note:** IE7 and earlier versions do not support the "inherit" value. IE8 supports "inherit" only if a !DOCTYPE is specified. IE9 supports "inherit".


Tips and Notes

**Tip:** In addition to a background image, you should also specify a background color. If the image is unavailable, the background color will be used.


Example

Example

Set the background image:

Runoob Tutorial(runoob.com)

Hello World!


Try it »


Style Object Reference The Style object