Export (0) Print
Expand All

background-position property

Specifies the position of the background of the object.

CSS Backgrounds and Borders Module Level 3, Section 3.6



background-position: [ [ percentage | length | left | center | right ] [ percentage | length | top | center | bottom ]? ] | [ [ left | center | right ] || [ top | center | bottom ] ]

Property values

One or two of the following values.


Integer, followed by a percent sign (%). The value is a percentage of the width or height of the object.


Floating-point number, followed by a supported length unit.

Horizontal alignment value.


Horizontal alignment is to the left.


Horizontal alignment is centered.


Horizontal alignment is to the right.

Vertical alignment value.


Vertical alignment is at the top.


Vertical alignment is centered.


Vertical alignment is at the bottom.

CSS information

Applies ToAll elements
Initial Value0% 0%

Standards information


If only one value is set, that value applies to the horizontal coordinate, and the vertical is set to "50%". If both values are set, the first value applies to the horizontal coordinate and the second value applies to the vertical.

Setting the values to "0% 0%" (initial value) positions the background-image to the upper left corner of the element's content block, which includes the padding.

Setting the background position using pixels positions the upper-left of the image at the specified x and y coordinates within the parent element. As the coordinates increase, the image moves to the right and down the visible area. By contrast, setting the background position with percentages uses a corresponding point on the image. At a position of "50% 50%" the image is effectively centered within the visible area.

This property can be set with the other background properties using the background composite property.

Starting in Windows Internet Explorer 9, the background of an element can have multiple layers. The number of layers is determined by the number of comma-separated values in the background-image property. Each of the images is sized, positioned, and tiled according to the corresponding value in the other background properties (background-attachment, background-clip, background-origin, background-position, background-repeat, and background-size). The first image in the list is the layer closest to the user, the next one is painted behind the first, and so on.

As of Internet Explorer for Windows Phone 8.1 Update, Internet Explorer for Windows Phone supports "-webkit-background-position" as an alias for this property.


The following example shows how to use background-position to specify different background position settings for three div objects.

   <div class="circle"></div>
   <div class="square"></div>
   <div class="triangle"></div>

In the first div object, background-position is set to 90% 50%. This represents a horizontal offset of 90% relative to the width of the object and a vertical offset of 50% relative to its height. In the second div object, the value for background-position is left bottom, which is equivalent to 0% for the horizontal position and 100% for the vertical position. In the third div object, background-position is set to 50px 50px, which sets the vertical and horizontal positions at 50 pixels.

Three divs with background images demonstrating the background-position property

div {
   width: 150px;
   height: 150px;
   background-color: #D3D3D3;
.circle {
   background-repeat: no-repeat;
   background-position: 90% 50%;
.square {
   background-repeat: no-repeat;
   background-position: left bottom;
.triangle {
   background-repeat: no-repeat;
   background-position: 50px 50px;

See also




© 2014 Microsoft