CSS object-position Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Images & Media

What You’ll Learn

The object-position property controls which part of an image or video stays visible inside its container. It is especially helpful when content is cropped by object-fit: cover and you need to keep the subject in frame.

01

Content Alignment

Anchor media inside a box.

02

Syntax

Keywords, %, and lengths.

03

Keywords

top, center, bottom, left, right.

04

Percentages

Fine-tune visible area.

05

Default Center

Starts at 50% 50%.

06

With object-fit

Control crop focus.

Introduction

The object-position property in CSS is used to specify the alignment of the content within a replaced element, such as an image or a video.

This property is particularly useful when the content is larger than the element’s box and gets cropped. By adjusting the position, you can control which part of the content is visible within the element.

Definition and Usage

The object-position CSS property sets the anchor point of replaced content inside its box. Think of it like choosing which corner or center of a photo should stay visible when the frame is smaller than the image.

It works best alongside sizing properties and often pairs with object-fit when you want responsive thumbnails, avatars, or hero banners that crop cleanly without losing the important subject.

💡
Beginner Tip

If a face or logo gets cut off inside a cropped image, try object-position: top center or object-position: center left before changing the container size.

📝 Syntax

The syntax for the object-position property is straightforward. It allows you to specify the position of the content within the element using keywords, percentages, or length units:

syntax.css
element {
  object-position: value;
}

Basic Example

object-position.css
img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: bottom right;
}

Syntax Rules

  • Use one or two values for horizontal and vertical alignment.
  • Keywords such as top, center, and right can be combined.
  • Percentages and lengths offer precise control over the visible area.
  • It is most visible when content overflows or is cropped by object-fit.

🎯 Default Value

The default value of the object-position property is 50% 50%, which centers the content within the element both horizontally and vertically.

That is why many cropped images look balanced by default, and you only need to change the value when the subject is near an edge of the photo.

⚡ Quick Reference

QuestionAnswer
Initial value50% 50%
Applies toReplaced elements such as img, video, and iframe
InheritedNo
AnimatableYes, as a position
Common useReframing cropped photos, avatars, and hero images

💎 Property Values

The object-position property accepts various values to define the position. Values can be combined to set both horizontal and vertical alignment.

Value typeExampleDescription
Keywordsobject-position: top right;Uses top, bottom, left, right, and center
Percentageobject-position: 25% 75%;Positions content relative to the element’s box
Lengthobject-position: 10px 20px;Uses units such as px, em, or rem
Mixed valuesobject-position: left 20%;Combines keywords with percentages or lengths
Single valueobject-position: top;Missing second value defaults to center
center — default focus top center — portraits bottom right — corner focus 25% 75% — fine control

Supported Elements

object-position applies to replaced elements whose content comes from an external resource:

  • <img> — the most common use case for thumbnails and avatars.
  • <video> — useful for reframing cropped background videos.
  • <iframe> — can shift embedded content within a responsive frame.

For visible results, give the element a defined box and pair with object-fit when the media should fill or crop inside that box.

👀 Live Preview

The same image uses object-fit: cover in identical frames. Only object-position changes:

center
top
bottom right
left center
25% 75%

Examples Gallery

Use object-position to keep the most important part of an image visible inside a cropped frame.

📍 Alignment Basics

Start with keyword values when you want to shift focus to a corner or edge of the image.

Example 1 — Focus on bottom right

In this example, an image larger than its container is aligned to the bottom-right corner so that area stays visible.

bottom-right.html
<style>
  .container {
    width: 200px;
    height: 200px;
    overflow: hidden;
  }

  .container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: bottom right;
  }
</style>

<div class="container">
  <img src="/images/bg-image.webp" alt="Example image">
</div>
Try It Yourself

How It Works

Because the image fills the box with cover, edges are cropped. bottom right keeps the lower-right area in view.

Example 2 — Portrait with top center

Use top center when faces or headings near the top of a photo should stay visible in a short frame.

top-center.css
.hero img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  object-position: top center;
}
Try It Yourself

How It Works

The image still covers the frame, but the visible crop favors the top-middle area instead of the default center.

🎯 Precise Control

Use percentages and combined values when keyword alignment is not exact enough.

Example 3 — Percentage positioning

Percentages let you nudge the visible area with more precision than keywords alone.

percentage-position.css
.feature img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 25% 75%;
}
Try It Yourself

How It Works

25% 75% anchors the image so the point 25% across and 75% down from the top-left aligns with the box.

Example 4 — Circular avatar crop

Combine a square frame, object-fit: cover, and object-position for profile photos.

avatar-position.css
.avatar {
  width: 96px;
  height: 96px;
  border-radius: 999px;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}
Try It Yourself

How It Works

The circular frame crops the image, and center top keeps the upper area of the photo in view for headshots.

Pair with object-fit

object-position works best when the browser has already decided how content should fit. Use object-fit: cover or contain first, then adjust position to control what remains visible.

fit-and-position.css
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

♿ Accessibility

  • Do not crop out meaning — If repositioning hides important content, choose a different crop or image.
  • Keep alt text accurate — Describe the image itself, not just the visible cropped portion.
  • Test on small screens — A position that works on desktop may crop differently on mobile.
  • Avoid text inside images — Cropping can remove words users need to read.

🧠 How object-position Works

1

Content is sized to the box

Width, height, and often object-fit determine how the media fills the container.

Layout
2

You choose an anchor point

Keywords, percentages, or lengths set where the content should align inside the box.

object-position
3

Overflow is reframed

When content is larger than the box, a different position reveals another part of the image or video.

Rendering
=

Better cropped media

The important subject stays visible even when the frame does not match the original image ratio.

Browser Compatibility

The object-position property is widely supported in modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. Verify compatibility and test across browsers to ensure consistent rendering.

Baseline · Modern browsers

Reliable support for media alignment

Chrome, Edge, Firefox, Safari, and Opera all support object-position in current versions.

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

Fallback behavior

When unsupported, content stays centered similar to the default 50% 50% behavior.

💻
Internet Explorer No support · Consider background-image positioning as a fallback
None
object-position property 97% supported

Bottom line: Use object-position confidently with object-fit in modern responsive layouts.

Conclusion

The object-position property is a useful tool for controlling the alignment of content within replaced elements. It allows you to ensure that the most important part of the content is visible, even when the element’s size does not match the content’s dimensions.

Experimenting with different values can help you achieve the desired visual effect on your website, especially when combined with object-fit for responsive images and videos.

💡 Best Practices

✅ Do

  • Pair with object-fit: cover for cropped thumbnails
  • Use top center for portraits and headshots
  • Try percentages when keyword alignment is not exact enough
  • Test crops on mobile and desktop breakpoints
  • Keep important subjects away from frame edges when possible

❌ Don’t

  • Expect visible changes without overflow or cropping
  • Confuse object-position with background-position
  • Hide critical product details with aggressive cropping
  • Forget that the default is already centered
  • Rely on position alone without sizing the media box

Key Takeaways

Knowledge Unlocked

Five things to remember about object-position

Use these points when reframing cropped media.

5
Core concepts
📝 02

Keywords

top, center, right, etc.

Values
📐 03

50% 50% Default

Centers content.

Default
🖼️ 04

With object-fit

Best for cropped media.

Companion
🎯 05

Fine Control

Percentages and lengths.

Precision

❓ Frequently Asked Questions

object-position controls which part of replaced content such as an image or video is visible inside its box, especially when the content is cropped or does not fill the container.
The default is 50% 50%, which centers the content horizontally and vertically within the element.
object-fit decides how content is scaled to fit the box. object-position decides where the content is anchored inside that box after scaling.
Yes. You can combine horizontal and vertical keywords such as top right, bottom center, or left center.
It is most useful with object-fit: cover when you need to keep faces, products, or logos in view after cropping.

Practice in the Live Editor

Open the HTML editor, apply object-position, and preview cropped images instantly.

HTML Editor →

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.

5 people found this page helpful