CSS background-position-y Property
Description
The background-position-y property in CSS allows developers to control the vertical placement of a background image within an element independently of its horizontal position. While background-position sets both horizontal and vertical positions simultaneously, background-position-y isolates the vertical axis, enabling precise alignment along the top-to-bottom dimension of a container. This is particularly useful for elements with fixed heights or when designers want specific parts of an image - such as a logo or decorative detail - to remain visible, regardless of horizontal alignment. By specifying how far from the top or bottom an image should be positioned, this property ensures a consistent visual layout across different screen sizes and element dimensions.
One practical use of background-position-y is in creating responsive designs where the vertical focus of a background image needs adjustment based on viewport size. For example, a hero section might require the center of an image to remain visible on mobile devices while showing more of the top portion on larger screens. Adjusting background-position-y allows for these changes without needing multiple image assets or altering the horizontal alignment. Additionally, it can be combined with CSS animations to produce vertical movement effects, such as scrolling backgrounds or subtle parallax effects, enhancing the interactivity and depth of a webpage.
background-position-y also works in tandem with other background properties to control the overall presentation of images. When paired with background-repeat, developers can control whether a vertically repeated image aligns correctly within its container, avoiding awkward tiling or clipping. Similarly, when used alongside background-size, it allows designers to shift the focal point of a scaled image vertically, maintaining visual balance and emphasis. In essence, background-position-y provides fine-tuned control over vertical alignment, helping create visually cohesive and flexible designs that adapt seamlessly to different layouts and device sizes.
Definition
- Initial value
- 0%
- Applies to
- all elements
- Inherited
- no
- 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
- Animatable
- a repeatable list
- JavaScript syntax
- object.style.backgroundPositionY
Interactive Demo
Syntax
background-position-x: top | center | bottom | <percentage> | <size>
Values
- topAligns the background to the top edge. Equivalent to writing 0 or 0%.
- centerAligns the background to the vertical center. Equivalent to 50% entry.
- bottomAligns the background to the bottom edge. Record equivalent to 100%.
- <percentage>Sets the background position as a percentage of the elements height. A value of 0% or 0 aligns the top edge of the background image to the top edge of the element. A value of 100% aligns the bottom edge of the picture with the bottom 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 top edge of the element.
Example
Browser Support
The following information will show you the current browser support for the CSS background-position-y property. Hover over a browser icon to see the version that first introduced support for this CSS property.
This property is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 1st January 2026
