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

HTML DOM Style backgroundAttachment property

Style backgroundAttachment property

Style Object Reference The Style object


Definition and Usage

The backgroundAttachment property sets or returns whether a background image is fixed or scrolls with the rest of the page.

Syntax

Set the backgroundAttachment property:

Object.style.backgroundAttachment="scroll|fixed|local"

Return the backgroundAttachment property:

Object.style.backgroundAttachment

Value Description
scroll The background scrolls with the element. This is the default.
fixed The background is fixed.
local The background scrolls with the content of the element.

Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the backgroundAttachment property.


Example

Example

Set the background image to fixed (not scrolling):

Runoob Tutorial(runoob.com)


Hello World!

This is a paragraph

This is a paragraph

This is a paragraph

This is a paragraph

This is a paragraph

This is a paragraph

This is a paragraph

This is a paragraph

This is a paragraph

This is a paragraph

This is a paragraph

This is a paragraph

This is a paragraph

This is a paragraph

This is a paragraph

Try it »


More examples

Toggle between scroll and fixed
Toggle between the scroll and fixed values of backgroundAttachment.


Style Object Reference The Style object