CSS background-position-y Property

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The background-position-y property sets the vertical starting place of each background-image. The place is measured inside the area from background-origin. Horizontal place stays as it is, or you set it with background-position-x.

The initial value is 0% (top). The property is not inherited. A later background or background-position declaration overrides it. Pair it with background-repeat: no-repeat when you want one clear marker.

Standard.

Not deprecated. Keywords, lengths, and percentages are Baseline. Side-relative values such as bottom 20px are widely supported in current browsers. Logical keywords y-start and y-end are newer and still limited.

CSS Syntax

syntax.css
background-position-y: top | center | bottom | 25% | 20px | bottom 20px | initial | inherit;

Separate multiple images with commas. The keyword comes before a side offset: bottom 20px, not 20px bottom.

Property Values

ValueDescriptionTry it
topAligns the image to the top edge. Same idea as 0%Try it
centerCenters the image on the vertical axisTry it
bottomAligns the image to the bottom edge. Same idea as 100%Try it
25%Lines up that point on the image with the same point on the boxTry it
20pxA length offset from the top edge of the positioning areaTry it
bottom 20pxSide-relative offset. Align to an edge, then nudge inwardTry it
0, centerOne vertical place per image in a comma-separated listTry it
initialResets this property to 0%Try it
inheritCopies this property from the parent elementTry it

How to Use background-position-y

Give the element an image, keep one copy visible, then set only the vertical place.

  1. Set a background-image on the element. Without an image, there is nothing to place.
  2. Give the element a visible size. Content or a height is enough.
  3. Use background-repeat: no-repeat when you want one image, not a tile.
  4. Set background-position-y for the vertical place. Use background-position-x if you also need the horizontal place.
PieceRequired?Role
background-imageYesThe picture or gradient you are placing
A visible boxYesContent or a height, so the place has somewhere to show
background-position-yYesVertical keyword, percentage, length, or side offset
background-position-xNoHorizontal place, if you want the axes in separate rules
background-repeatOftenno-repeat keeps a single placed image easy to see

Live Preview

One blue marker, kept horizontally centered. Change background-position-y and watch it move up and down.

Horizontal place stays center. Only the vertical place changes.

Vertical place

background-position-y: center

CSS Examples

Each snippet adds only what background-position-y 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 Vertically

Place the marker in the vertical middle. Horizontal place stays center.

CSS
<style>
  div {
    height: 160px;
    border: 1px solid #ccc;
    background-color: #eff6ff;
    background-image: radial-gradient(circle, #2563eb 0 28px, transparent 29px);
    background-repeat: no-repeat;
    background-size: 72px 72px;
    background-position-x: center;
    background-position-y: center;
  }
</style>

<div></div>
Try It Yourself

How It Works

  1. Make a box. height: 160px and the border give the image a clear area.
  2. Paint a marker. The radial gradient is a blue circle used as the background image. background-size keeps it small.
  3. Stop the tile. background-repeat: no-repeat shows one circle so vertical placement is easy to see.
  4. Center on Y. background-position-y: center moves only up and down. background-position-x: center keeps the horizontal middle steady.

Example 2 — Percentage on Y

Line up a vertical point on the image with the same point on the box.

CSS
<style>
  div {
    height: 160px;
    border: 1px solid #ccc;
    background-color: #ecfdf5;
    background-image: radial-gradient(circle, #059669 0 28px, transparent 29px);
    background-repeat: no-repeat;
    background-size: 72px 72px;
    background-position-x: center;
    background-position-y: 25%;
  }
</style>

<div></div>
Try It Yourself

How It Works

  1. One axis only. 25% is vertical. Horizontal place is still center from the other property.
  2. Match points. The point 25% down the image meets the point 25% down the box.
  3. Edges are 0% and 100%. 0% is top. 100% is bottom. 50% is center.
  4. The image must be shorter. If the image matched the box height, 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 bottom edge, then nudge inward with a length.

CSS
<style>
  div {
    height: 160px;
    border: 1px solid #ccc;
    background-color: #fff7ed;
    background-image: radial-gradient(circle, #ea580c 0 28px, transparent 29px);
    background-repeat: no-repeat;
    background-size: 72px 72px;
    background-position-x: center;
    background-position-y: bottom 20px;
  }
</style>

<div></div>
Try It Yourself

How It Works

  1. Name the edge first. bottom chooses the bottom edge of the positioning area.
  2. Offset after the edge. 20px follows bottom, so the circle moves 20px upward from that edge.
  3. Order matters. bottom 20px is valid. 20px bottom is not.
  4. Use this for a gap from an edge. Plain bottom sticks to the edge. The length leaves a small inset.

Edge Cases & Pitfalls

If the vertical 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-y. 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 Y place is obvious.

size

A full-height image ignores percentages

If background-size matches the box height, a percentage has no leftover space. Use a length, or make the image shorter than the box.

order

20px bottom is invalid

A side-relative value needs the keyword first: bottom 20px or top 25%. A bare length alone is measured from the top.

axis

This property never moves X

Only the vertical place changes. For horizontal place, use background-position-x or the two-axis background-position shorthand.

Browser Support

background-position-y 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-y

Keywords, lengths, percentages: Chrome 1+, Firefox 49+, Safari 1+, Edge 12+, Opera 15+. Side-relative offsets such as bottom 20px: current Chromium, Firefox, and Safari. Logical y-start / y-end: limited.

98% Keywords and lengths
Google Chrome 1+
Full support
Mozilla Firefox 49+
Full support
Apple Safari 1+
Full support
Microsoft Edge 12+
Full support
Opera 15+
Full support
Samsung Internet 1+
Full support
Internet Explorer 6+
Partial
background-position-y Widely supported

Bottom line: Safe for top, center, bottom, lengths, and percentages in current browsers. Firefox added the property in 49. Side-relative values such as bottom 20px are fine in current browsers. Prefer physical keywords over y-start / y-end on a normal page.

Key Takeaways

  • Role: set only the vertical place of each background image.
  • Values: top, center, bottom, percentages, lengths, or side offsets such as bottom 20px.
  • Initial value: 0% (top). It is not inherited.
  • Override: a later background or background-position resets this longhand.

One line: background-position-y moves the image up and down — pair it with background-position-x when you also need left and right.

Frequently Asked Questions

It sets only the vertical place of each background image inside the area from background-origin. Horizontal place is unchanged, or controlled with background-position-x. The initial value is 0%, which is the top edge.
0%. That lines up the top edge of the image with the top edge of the positioning area. The property is not inherited.
background-position can set both axes in one declaration. background-position-y sets only the vertical axis. A later background or background-position rule overrides background-position-y.
Yes. Set vertical place with background-position-y and horizontal place with background-position-x when you want the axes in separate rules.
It is a side-relative value. The image aligns to the bottom edge, then moves 20px inward from that edge. top 25% works the same way from the top.
Keywords, lengths, and percentages are Baseline and widely available since 2016. Side-relative values such as bottom 20px have solid support in current browsers. Logical keywords such as y-start are newer and still limited. This is a browser CSS property. Node.js, Deno, and Bun do not paint it.

Next: background-repeat

Learn how to tile a background image, or show it only once.

background-repeat tutorial →

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.

8 people found this page helpful