CSS background-attachmentProperty


Example

How to specify a fixed background image:

body { background-image:url('smiley.gif'); background-repeat:no-repeat; background-attachment:fixed; }

Try it Yourself »

Tag definition and usage instructions

background-attachment sets whether the background image is fixed or scrolls with the rest of the page.

Default Value: scroll
Inherited: no
version: CSS1
JavaScript Syntax: object object.style.backgroundAttachment="fixed"


Browser Support

The numbers in the table indicate the first browser version number that supports the property.

The number preceding -webkit-, -ms-, or -moz- is the first browser version number that supports the prefixed property.

Property
background-attachment 1.0 4.0 1.0 1.0 3.5

Note: Internet Explorer 8 and earlier browsers do not support multiple background images on one element.


Property value

Value Description
scroll The background image scrolls with the scrolling of the page; this is the default.
fixed The background image does not scroll with the scrolling of the page.
local The background image scrolls with the scrolling of the element's content.
initial Set the default value of this attribute.Read Aboutinitialcontent
inherit Specifies that the background-attachment setting should be inherited from the parent element.Read Aboutinheritcontent


Related Articles

CSS Tutorial:CSS Background

other extensions