CSS background-attachment Property

Definition and Usage

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

See Also:

CSS Tutorial:CSS Background

HTML DOM Reference Manual:backgroundAttachment Property

Example

How to Set a Fixed Background Image:

body 
  { 
  background-image: url(bgimage.gif); 
  background-attachment: fixed;
  }

Try It Yourself

CSS Syntax

background-attachment: scroll|fixed|local|initial|inherit;

Attribute Value

Value Description
scroll Default Value. The background image will move with the rest of the page scrolling.
fixed The background image will not move when the rest of the page scrolls.
inherit Specifies that the background-attachment property should inherit the setting from the parent element.

Technical Details

Default Value: scroll
Inheritance: no
Version: CSS1
JavaScript Syntax: object.style.backgroundAttachment="fixed"

Browser Support

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

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
1.0 4.0 1.0 1.0 3.5