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

HTML DOM Style background property

Style background property

Style Object Reference The Style object


Definition and Usage

The background property sets or returns up to five separate background properties in shorthand form.

With this property, you can set/return:

The properties above can also be set with individual style properties. Using individual properties is strongly recommended for better control.

Syntax

Set the background property:

Object.style.background="

color image repeat attachment position

"

Return the background property:

Object.style.background

**Tip:** The default value of the background property is: transparent none repeat scroll 0% 0%.

Parameters Description
color Set the background color of an element
image Set the background image of an element
repeat Set how the background image is repeated
attachment Set whether the background image is fixed or scrolls with the rest of the page
position Set the starting position of the background image

Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the background attribute.


Example

Example

Set the style of the document background:

Runoob Tutorial(runoob.com)

Hello World!


Try it »


Style Object Reference The Style object