Background

HTML Fixed Background Code

Scroll the preview below — the background image stays anchored in place, a simple parallax-style effect.

Live Tool

Scroll inside the preview panel on the right to see the fixed effect.

fixed-bg.cssLive

          
Preview — scroll inside this box
Keep scrolling — the image stays put

1How To Use

Follow these steps — no coding experience needed.

  1. Add a tall imageFixed backgrounds work best with images taller than the visible box.
  2. Copy the CSSbackground-attachment: fixed is the key line.
  3. Test on mobileSome mobile browsers render fixed backgrounds as scrolling instead — test on real devices.

2Example Output

What this code looks like once it's on a real page.

Fixed backgrounds are often used for full-page hero sections that create a subtle depth effect as visitors scroll.

3Browser Compatibility

BrowserSupportNotes
Desktop Chrome✓ SupportedFull support
Desktop Firefox✓ SupportedFull support
Desktop Safari✓ SupportedFull support
iOS Safari⚠ PartialOften renders as scroll instead of fixed
Android Chrome⚠ PartialBehaviour varies by device

Supported in every current browser — Chrome, Firefox, Safari, Edge and Opera all render this identically, on both desktop and mobile.

Related Pages

More tools that pair naturally with this one.