The background-attachment property decides what a background-image is locked to when scrolling happens. The image can stick to the element (scroll), to the viewport (fixed), or to the element's own overflowing content (local).
The initial value is scroll. The property is not inherited. It applies to every element, including ::first-letter and ::first-line. With several images, list one keyword per layer, separated by commas. With fixed, background-origin is ignored.
Standard-track.
Not deprecated and not experimental. Baseline widely available. On many iOS Safari versions, fixed still behaves like scroll by design — see Edge Cases.
Syntax
CSS Syntax
syntax.css
background-attachment:scroll | fixed | local | initial | inherit;
For multiple images, write a comma list such as fixed, scroll. Each keyword matches one image in the same order.
Values
Property Values
Value
Description
Try it
scroll
Default. Image sticks to the element. Inner overflow does not move it
When the image is pinned to the viewport, background-origin is ignored for that layer. Position is relative to the viewport instead.
a11y
Background images are decoration
Screen readers do not announce background images. Put meaning in an img with alt, and keep text contrast strong over moving paint.
Compatibility
Browser Support
background-attachment is a browser painting property. Node.js, Deno, and Bun do not apply it. scroll and fixed are older than local. fixed remains a known weak spot on iOS Safari.
✓ Baseline · Widely available since 2015
background-attachment
scroll: every current browser. fixed: desktop browsers yes; iOS Safari often acts like scroll. local: Chrome 4+, Firefox 25+, Safari 5+ (full again from 15.4), Edge 12+, Internet Explorer 9+.
95%Desktop support
Google Chrome1+ scroll/fixed · 4+ local
Full support
Mozilla Firefox1+ scroll/fixed · 25+ local
Full support
Apple Safari1+ scroll/fixed · 5+ local
Full support
Microsoft Edge12+
Full support
Opera15+ local · fixed on desktop
Full support
Samsung Internet4+
Full support
Internet Explorer4+ scroll/fixed · 9+ local
Partial
background-attachmentWidely supported
Bottom line: Safe for scroll and local in current browsers. Treat fixed as a progressive enhancement: it fails open as scroll on many iPhones. Internet Explorer 8 and older lack local.
Remember
Key Takeaways
Role: choose whether the background image locks to the element, the viewport, or the element's content.
Keywords:scroll (default), fixed (viewport), local (inner content).
Layers: one keyword per image, in the same order as background-image.
Mobile: do not rely on fixed alone on iOS Safari.
One line:background-attachment answers “what does this image stay stuck to when something scrolls?”
Frequently Asked Questions
It chooses what a background image is fixed to when scrolling happens: the element (scroll), the viewport (fixed), or the element's own overflowing content (local).
scroll. The image is stuck to the element. When you scroll the page, the image moves with that element. When you scroll inside the element, the image stays put against the element's border.
Both move with the page when the element moves. Inside a scrollable box, scroll keeps the image glued to the box edge, while local moves the image with the text as you scroll that box.
It pins the image to the viewport. As the page scrolls, the element moves over a background that stays in place. On that value, background-origin is ignored.
Often no. On many iOS Safari versions, fixed behaves like scroll by design. Test on a real device, and prefer a position: fixed layer if you need a reliable pinned backdrop on mobile.
scroll and fixed are Baseline and very old. local needs Chrome 4, Firefox 25, Safari 5, Edge 12, or Internet Explorer 9. fixed is unreliable on iOS Safari. This is a browser painting property. Node.js, Deno, and Bun do not apply it.