CSS background-position Property Explained
What the CSS background-position property does, with an example.
Published November 6, 2026
background-position sets where a background image sits inside its box using keywords (top, center, bottom, left, right), lengths or percentages.
How it works
Percentages align the same point of image and box (50% 50% centres). With cover, position decides which part stays visible.
Shorthand: background: url() center / cover.
Values and effects
background-position: center; → centred
background-position: top right; → corner
background-position: 50% 25%; → custom
background-position: 10px 20px; → offset
Practical examples
Centre a hero
.hero { background: url(a.jpg) center center / cover; }Keep a face visible
.cover { background-position: top center; }Icon with offset
.btn { background: url(arrow.svg) right 12px center no-repeat; }Common mistakes
- Forgetting the size, so position has little effect.
- Mixing percentages and keywords wrongly.
- Not testing different aspect ratios.
Key takeaways
- background-position in one line: background-position sets where a background image sits inside its box using keywords (top, center, bottom, left, right), lengths or percentages.
- Inspect it live in DevTools → Styles.
- Test across browsers and screen sizes.
FAQ
What does 50% 50% mean?
The image's centre aligns with the box's centre.
Is background-position supported in all browsers?
Yes in all modern browsers; check caniuse.com for edge cases.