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

CSS background-attachment Property

CSS background-attachment Property

Example

How to specify a fixed background image:

body

{

background-image:

url

('

smiley

.

gif

')

;

background-repeat:

no-repeat

;

background-attachment:

fixed

;

}

Try it »


Tag Definition and Usage Notes

background-attachment sets whether a 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 that supports this property.

A number immediately before -webkit-, -ms-, or -moz- indicates the first browser version that supports that 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 a single element.


Attribute values

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

Related Articles

CSS Tutorial: CSS Background