The background-position-x property sets the horizontal starting place of each background-image. The place is measured inside the area from background-origin. Vertical place stays as it is, or you set it with background-position-y.
Not deprecated. Keywords, lengths, and percentages are Baseline. Side-relative values such as right 20px are widely supported in current browsers. Logical keywords x-start and x-end are newer and still limited.
Syntax
CSS Syntax
syntax.css
background-position-x:left | center | right | 25% | 20px | right 20px | initial | inherit;
Separate multiple images with commas. The keyword comes before a side offset: right 20px, not 20px right.
Values
Property Values
Value
Description
Try it
left
Aligns the image to the left edge. Same idea as 0%
One blue marker, kept vertically centered. Change background-position-x and watch it move left and right.
Vertical place stays center. Only the horizontal place changes.
Horizontal place
center
background-position-x: center
Code
CSS Examples
Each snippet adds only what background-position-x needs: an image, a sized box, and no-repeat so the mark is clear. Use Try It Yourself for a live editor.
Example 1 — Center Horizontally
Place the marker in the horizontal middle. Vertical place stays center.
One axis only.25% is horizontal. Vertical place is still center from the other property.
Match points. The point 25% across the image meets the point 25% across the box.
Edges are 0% and 100%.0% is left. 100% is right. 50% is center.
The image must be smaller. If the image matched the box width, a percentage would have no room to slide. Here the circle is smaller, so the move is visible.
Example 3 — Side Offset
Anchor to the right edge, then nudge inward with a length.
Name the edge first.right chooses the right edge of the positioning area.
Offset after the edge.20px follows right, so the circle moves 20px inward from that edge.
Order matters.right 20px is valid. 20px right is not.
Use this for a gap from an edge. Plain right sticks to the edge. The length leaves a small inset.
Edge Cases & Pitfalls
If the horizontal place looks wrong or resets, one of these is usually why.
override
background-position wins later
A later background-position or background rule overrides background-position-x. Set the longhand after the shorthand, or put the place inside the shorthand.
repeat
Tiles hide a clear placement
The initial background-repeat is repeat. Use no-repeat when you want one image so the X place is obvious.
size
A full-width image ignores percentages
If background-size matches the box width, a percentage has no leftover space. Use a length, or make the image narrower than the box.
order
20px right is invalid
A side-relative value needs the keyword first: right 20px or left 25%. A bare length alone is measured from the left.
background-position-x is a browser painting property. Node.js, Deno, and Bun do not apply it. Keywords, lengths, and percentages are Baseline. Side-relative values and logical keywords have narrower history.
✓ Baseline · Widely available since 2016
background-position-x
Keywords, lengths, percentages: Chrome 1+, Firefox 49+, Safari 1+, Edge 12+, Opera 15+. Side-relative offsets such as right 20px: current Chromium, Firefox, and Safari. Logical x-start / x-end: limited.
98%Keywords and lengths
Google Chrome1+
Full support
Mozilla Firefox49+
Full support
Apple Safari1+
Full support
Microsoft Edge12+
Full support
Opera15+
Full support
Samsung Internet1+
Full support
Internet Explorer6+
Partial
background-position-xWidely supported
Bottom line: Safe for left, center, right, lengths, and percentages in current browsers. Firefox added the property in 49. Side-relative values such as right 20px are fine in current browsers. Prefer physical keywords over x-start / x-end on a normal page.
Remember
Key Takeaways
Role: set only the horizontal place of each background image.
Values:left, center, right, percentages, lengths, or side offsets such as right 20px.
Initial value:0% (left). It is not inherited.
Override: a later background or background-position resets this longhand.
One line:background-position-x moves the image left and right — pair it with background-position-y when you also need up and down.
Frequently Asked Questions
It sets only the horizontal place of each background image inside the area from background-origin. Vertical place is unchanged, or controlled with background-position-y. The initial value is 0%, which is the left edge.
0%. That lines up the left edge of the image with the left edge of the positioning area. The property is not inherited.
background-position can set both axes in one declaration. background-position-x sets only the horizontal axis. A later background or background-position rule overrides background-position-x.
Yes. Set horizontal place with background-position-x and vertical place with background-position-y when you want the axes in separate rules.
It is a side-relative value. The image aligns to the right edge, then moves 20px inward from that edge. left 25% works the same way from the left.
Keywords, lengths, and percentages are Baseline and widely available since 2016. Side-relative values such as right 20px have solid support in current browsers. Logical keywords such as x-start are newer and still limited. This is a browser CSS property. Node.js, Deno, and Bun do not paint it.