CSS background-position Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Backgrounds & Layout

What You’ll Learn

The background-position property sets where a background image starts inside an element. You can use keywords, percentages, or pixel values to place backgrounds exactly where you want them.

01

Placement

Move background images.

02

Keywords

top, left, center.

03

Percentages

Relative positioning.

04

Pixels

Exact distances.

05

Two Values

Horizontal and vertical.

06

With origin

Works with background-origin.

Definition and Usage

The background-position CSS property sets the initial position of a background image. It controls the horizontal and vertical placement of the background within the element’s background positioning area.

This is especially useful when the background does not fill the entire element, such as a small icon, badge, texture, or photo positioned in a corner or centered in a hero section.

💡
Beginner Tip

To see background-position clearly, use background-repeat: no-repeat; and a smaller background-size so the image does not cover the whole box.

📝 Syntax

Apply background-position using one or two values:

syntax.css
selector {

  background-position: <position>;

}

Basic Example

background-position.css
.hero {

  background-image: url("hero.jpg");

  background-position: center;

  background-size: cover;

}

Common Value Forms

  • One keyword: center, top, bottom
  • Two keywords: top left, bottom right
  • Percentages: 50% 50%, 75% 25%
  • Length units: 20px 30px, 1rem 2rem
  • Mixed values: center top, right 20px bottom 10px

Syntax Rules

  • The initial value is 0% 0%, which is equivalent to top left.
  • The first value usually controls the horizontal position; the second controls the vertical position.
  • If only one value is given, the second value defaults to center for keywords or 50% in some mixed cases depending on syntax.
  • It works with images, gradients, and multiple background layers.
  • The positioning area is affected by background-origin.

⚡ Quick Reference

QuestionAnswer
Initial value0% 0% (top left)
Applies toBackground images of an element
InheritedNo
AnimatableYes
Common useHero photos, corner icons, centered backgrounds

Default Value

The initial value of background-position is 0% 0%. That places the background at the top-left corner of the background positioning area.

💎 Property Values

These are the most common ways to set background-position.

Value typeExampleMeaning
Keywordbackground-position: center;Centers the background in the element
Two keywordsbackground-position: top left;Places the background in the top-left corner
Percentagebackground-position: 50% 50%;Centers using relative percentages
Lengthbackground-position: 20px 30px;Offsets the background by exact distances
Mixedbackground-position: right 1rem bottom 1rem;Combines edge keywords with offset distances
keywords

Easy preset positions such as center, top left, and bottom right.

Best for quick layout choices.

percentages

Positions relative to the container size, such as 75% 25%.

Useful for responsive layouts.

pixels

Exact offsets like 20px 30px for precise decorative placement.

Good for badges and icons.

mixed

Combine keywords and lengths, such as center top or right 20px bottom 10px.

Flexible real-world syntax.

background-position vs background-origin

PropertyControlsBest for
background-positionWhere the background image is placedCentering photos, corner icons, offset textures
background-originWhich box is used as the positioning areaAligning backgrounds with border, padding, or content edges

👀 Live Preview

These panels use the same small background marker. Only the position value changes:

center
top left
bottom right

Use non-repeating backgrounds to make placement differences easy to see.

Examples Gallery

Try background-position with center, corner keywords, percentages, and a multi-value comparison.

📚 Basic Placement

Start with simple keyword positioning before moving to percentages and pixel offsets.

Example 1 — Center the Background

Place a background image in the center of an element.

center-position.css
.hero {

  background-image: url("hero.jpg");

  background-position: center;

  background-size: cover;

}
Try It Yourself

How It Works

The keyword center places the background in the middle of the element both horizontally and vertically.

Example 2 — top left and bottom right

Use corner keywords to place a background marker in opposite corners.

corner-position.css
.top-left { background-position: top left; }

.bottom-right { background-position: bottom right; }
Try It Yourself

How It Works

Two keyword values set horizontal and vertical placement. top left and bottom right are common corner positions.

🎨 Percentages & Exact Offsets

Use relative and absolute values when you need more precise background placement.

Example 3 — Percentage Positioning

Position a background relative to the size of the element using percentages.

percent-position.css
.panel {

  background-image: radial-gradient(circle, #059669 0 30px, transparent 31px);

  background-repeat: no-repeat;

  background-size: 80px 80px;

  background-position: 75% 25%;

}
Try It Yourself

How It Works

The first value moves the background horizontally; the second moves it vertically, both relative to the element size.

Example 4 — Compare Multiple Positions

See how different position values move the same background marker to different places.

position-compare.css
.center { background-position: center; }

.top { background-position: top; }

.pixels { background-position: 20px 30px; }
Try It Yourself

How It Works

The same background settings can look very different depending on which position value you choose.

🧠 How background-position Works

1

You set a background image

Add an image or gradient with background-image.

Background
2

You choose a position

Use keywords, percentages, or pixel values in background-position.

Placement
3

The browser anchors the image

The background is placed relative to the background positioning area, which can be shaped by background-origin.

Reference box
=

Controlled background layout

You can center hero images, place icons in corners, and fine-tune decorative backgrounds.

Universal Browser Support

background-position is one of the most widely supported CSS properties and works reliably across modern and older browsers.

Baseline · All browsers

Position backgrounds everywhere

Chrome, Firefox, Safari, Edge, and Opera all support keyword, percentage, and length positioning values.

99% Universal support
Google Chrome1+ · Desktop & Mobile
Full support
Mozilla Firefox1+ · Desktop & Mobile
Full support
Apple Safari1+ · macOS & iOS
Full support
Microsoft Edge12+ · All versions
Full support
Opera3.5+ · Modern versions
Full support

Fallback behavior

Invalid position values are ignored, leaving the previous or default top-left placement in effect.

💻
Very old browsers May not support newer four-value offset syntax
Rare
background-position property 99% supported

Bottom line: Use background-position confidently in any web project.

Conclusion

The background-position property gives you precise control over where background images appear inside an element. Whether you center a hero photo or place a small decorative marker in a corner, this property makes background layout flexible and predictable.

Start with keywords like center and top left, then explore percentages and pixel offsets when you need finer control.

💡 Best Practices

✅ Do

  • Use center for hero images with background-size: cover;
  • Combine position with background-repeat and background-size
  • Use percentages for responsive decorative placement
  • Test important focal points on mobile and desktop
  • Pair with background-origin when borders or padding matter

❌ Don’t

  • Expect visible placement changes when the background fully covers the box
  • Forget that the default position is top left
  • Confuse background-position with background-origin
  • Crop important image content off-screen on small screens
  • Use pixel offsets everywhere when responsive percentages would work better

Key Takeaways

Knowledge Unlocked

Five things to remember about background-position

Use these points when placing backgrounds in your layouts.

5
Core concepts
📝02

Keywords

center, top, bottom, left, right.

Values
📊03

Percentages

Relative positioning.

Responsive
04

0% 0% Default

Top-left by default.

Default
🛠05

With Origin

Placement area matters.

Compare

❓ Frequently Asked Questions

The background-position property sets the starting position of a background image within an element. It controls where the background is placed horizontally and vertically.
The initial value is 0% 0%, which places the background at the top-left corner of the background positioning area.
Yes. Common keywords include top, bottom, left, right, and center. You can combine them, such as top left or bottom right.
Keywords are easy preset positions. Percentages position relative to the container size. Pixel values place the background an exact distance from the origin edge.
background-origin defines the positioning area, while background-position places the background image inside that area.

Practice in the Live Editor

Open the HTML editor, move background markers around, and experiment with background-position instantly.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful