CSS background-position-x Property


The background-position-x CSS property is a part of the background positioning properties used to control the horizontal placement of a background image within its containing element. It allows web developers to specify the precise position of the background image along the X-axis (horizontal axis) relative to the element's padding box. By setting a value for background-position-x, such as a length measurement or a percentage, developers can achieve fine-grained control over the horizontal alignment of background images, helping to create visually appealing and customized layouts for web pages. This property works in conjunction with background-position-y, which controls the vertical positioning of the background image.

Initial value
Applies to
all elements
Computed value
A list, each item consisting of: an offset given as a combination of an absolute length and a percentage, plus an origin keyword
a repeatable list
JavaScript syntax

Interactive Demo


background-position-x: left | center | right | <percentage> | <size>


  • leftAligns the background to the left. Equivalent to writing 0 or 0%.
  • centerAligns the background horizontally to the center. Equivalent to 50% entry.
  • rightAligns the background to the right. Record equivalent to 100%.
  • <percentage>Sets the background position as a percentage of the elements width. A value of 0% or 0 aligns the left edge of the background image to the left edge of the element. A value of 100% aligns the right edge of the picture with the right edge of the element.
  • <size>Sets the position of the background in any units available for CSS - pixels (px), centimeters (cm), em, etc. relative to the left edge of the element.


div {
  width: 250px;
  height: 250px;
  background-color: skyblue;
  background-image: url(images/icon2.png);
  background-repeat: no-repeat;
  background-position-x: left;
  background-position-y: bottom;

Browser Support

The following table will show you the current browser support for the CSS background-position-x property.

Edge Chrome Firefox Opera Safari
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview

Last updated by CSSPortal on: 1st January 2024