CSS object-position Property

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

Definition and Usage

The object-position property sets how the content of a replaced element — usually an <img> or <video> — is aligned inside the element’s box.

It pairs with object-fit. Fit chooses how the media scales; position chooses which part stays in view after cropping or letterboxing. Empty areas show the element’s background. The initial value is 50% 50% (center). It is not inherited.

Baseline · Widely available.

Not deprecated and not experimental. Keyword, length, and percentage values are safe in current browsers. Logical keywords such as x-start are newer and still missing in some browsers.

CSS Syntax

syntax.css
object-position: <position> | initial | inherit;

A position is one to four values: keywords (top, left, center), percentages, lengths, or an edge offset such as bottom 10px right 20px.

Property Values

ValueDescriptionTry it
centerDefault focus. Same idea as 50% 50%Try it
top left right bottomEdge keywords. Combine two, such as top rightTry it
25% 75%Percentage offsets. First is horizontal, second is verticalTry it
20px 10pxLength offsets from the top-left of the boxTry it
bottom 10px right 20pxEdge offsets. Each length follows the edge it offsets fromTry it
initialSets this property to its default value, 50% 50%Try it
inheritInherits this property from the parent elementTry it

How to Use object-position

Size the media, choose a fit mode that crops or leaves space, then steer the visible part.

  1. Use a replaced element such as <img> or <video>.
  2. Give it a defined width and height that can differ from the media’s natural size.
  3. Set object-fit — usually cover when you want to crop.
  4. Set object-position to keep the subject in view. It is not inherited.
PieceRequired?Role
Replaced elementYesimg, video, and similar
Defined width and heightYesWithout a sized box, there is nowhere to align
object-fitUsuallycover or none makes position changes easy to see
Position valueYesKeywords, percentages, lengths, or an edge offset

Live Preview

The same image uses object-fit: cover. Change object-position and watch which part stays in the frame.

object-fit: cover fills the frame. Position picks the crop focus.

Frame
Demo photo inside a fixed frame

object-position: center

CSS Examples

Each snippet adds only what object-position needs: a sized box, a fit mode, and a position. Use Try It Yourself for a live editor.

Example 1 — Keyword Focus

Crop with cover, then pin the visible area to the top-right corner.

CSS
<style>
  img {
    width: 240px;
    height: 140px;
    object-fit: cover;
    object-position: top right;
    border: 1px solid #ccc;
  }
</style>

<img src="/images/bg-image.webp" alt="Photo focused on top right">
Try It Yourself

How It Works

  1. Define the box. Fixed width and height create a frame that may not match the photo’s ratio.
  2. Crop with cover. object-fit: cover fills the frame and clips overflow.
  3. Steer the crop. object-position: top right keeps the top-right of the photo visible.
  4. One keyword is enough. A single keyword like top centers the other axis automatically.

Example 2 — Percentage Offsets

Place the focus with percentages when keywords are too coarse.

CSS
<style>
  img {
    width: 240px;
    height: 140px;
    object-fit: cover;
    object-position: 25% 75%;
    border: 1px solid #ccc;
  }
</style>

<img src="/images/bg-image.webp" alt="Photo focused with percentages">
Try It Yourself

How It Works

  1. Two values mean x then y. 25% is horizontal. 75% is vertical.
  2. Percentages refer to the element box. They resolve against the width and height of the media element itself.
  3. 50% 50% is the default. That is the centered position you get when the property is unset.
  4. Useful for faces. Nudge the crop until the subject sits where you want it.

Example 3 — Length Offsets

Offset from the top-left corner with exact lengths.

CSS
<style>
  img {
    width: 240px;
    height: 140px;
    object-fit: cover;
    object-position: 20px 10px;
    border: 1px solid #ccc;
  }
</style>

<img src="/images/bg-image.webp" alt="Photo offset with lengths">
Try It Yourself

How It Works

  1. First length is horizontal. 20px shifts from the left edge of the box.
  2. Second length is vertical. 10px shifts from the top edge.
  3. Same grammar as background-position. Edge offsets such as bottom 10px right 20px also work.
  4. Values can go outside the box. The object may be drawn partly outside; leftover space shows the background.

Edge Cases & Pitfalls

If the crop focus does not move, one of these is usually why.

fit

No crop, little to see

With the default object-fit: fill, or when the image already matches the box, position changes are hard to notice. Use object-fit: cover (or none) when teaching or debugging position.

size

Needs a sized box

Without width and height that differ from the media’s natural size, there is no frame to align inside. Size the element first.

order

Fit first, then position

object-fit decides how much is cropped. object-position only chooses which part of that result stays visible. They do not replace each other.

bg

Not the same as background-position

Same value grammar, different target. background-position moves a background-image. object-position moves the content of img or video.

a11y

Cropping can hide meaning

A bad crop can cut off faces or text. Keep meaningful alt text, and adjust position (or the frame ratio) when the subject matters.

Browser Support

object-position is a browser CSS property for replaced elements. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available since 2020

object-position

Chrome 31+, Firefox 36+, Safari 10+, Edge 16+, Opera 19+. Internet Explorer has no native support.

97% Modern browser support
Google Chrome 31+ · Desktop & Mobile
Full support
Mozilla Firefox 36+ · Desktop & Mobile
Full support
Apple Safari 10+ · macOS & iOS
Full support
Microsoft Edge 16+ · Chromium & Legacy
Full support
Opera 19+ · Modern versions
Full support
Samsung Internet 3+ · Android
Full support
Internet Explorer No support
None
object-position Widely supported

Bottom line: Safe for modern responsive layouts. Logical position keywords such as x-start are newer — stick to classic keywords, percentages, and lengths for widest support. Pair with object-fit: cover for card and avatar crops.

Key Takeaways

  • Role: choose which part of replaced media stays visible inside its box.
  • Default: 50% 50% (center). Not inherited.
  • Pair with cover: object-fit crops; object-position steers the crop.
  • Values: keywords, percentages, lengths, or edge offsets — same idea as background-position.

One line: after object-fit scales the media, object-position picks the focus inside the frame.

Frequently Asked Questions

It sets where replaced content such as an image or video sits inside its box. It is most useful when object-fit: cover crops the media and you need to keep a face or logo in view.
50% 50%, which centers the content horizontally and vertically. Writing center is the common keyword form of that default.
object-fit decides how the content is scaled (cover, contain, fill). object-position decides which part of that scaled content stays visible inside the box.
If the content already matches the box with no crop or letterbox, moving it has nothing to reveal. Pair it with object-fit: cover or none when the media is larger than the box.
Yes. Values can shift the object so part of it is drawn outside the element's box. Empty areas show the element's background.
It is Baseline and widely available: Chrome 31+, Firefox 36+, Safari 10+, Edge 16+, and Opera 19+. Internet Explorer has no support. It is a browser CSS property, not a Node.js feature.

Next: offset

Learn the CSS offset shorthand for motion path animations.

offset 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