Skip to navigation

CSS Property: background-attachment

Specifies if a background is fixed to the viewport or if it scrolls along with the contents of its containing box.

As an example, a background image applied to a long page will typically scroll with the rest of the page. If a fixed background-attachment is applied, however, the image will stay in the same position as the user scrolls the page up and down.

Possible Values

scrollThe background will scroll with the rest of the content. Default behaviour.
fixedThe background will remain stationary as the rest of the content is scrolled.


body { background-attachment: fixed; }