CSS Portal

CSS object-position Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The object-position property determines the alignment of a replaced element’s content (for example images, videos, or other embedded resources) within the element’s content box. It controls the focal point — where the source content is placed relative to the element’s box — so when the intrinsic size of the content does not match the box (due to scaling, cropping, or aspect-ratio preservation) the developer can decide which part of the content remains visible. Importantly, changing object-position does not alter the element’s laid-out box or the document flow; it only affects how the replaced resource is painted inside that box.

In practical use, object-position is often paired with object-fit, which governs how the content scales to fit the box. When content is scaled or cropped by object-fit, object-position specifies the location within the box that acts as the anchor or focal point for that scaling/cropping. That makes it useful for responsive image composition: you can maintain a consistent visible subject across differing aspect ratios and container sizes by shifting the focal area rather than altering layout or choosing a different image source.

Conceptually it is analogous to how backgrounds are positioned, but for replaced elements instead of background layers — compare with background-position, which affects background image placement and painting. It also differs from transform-related origin controls such as transform-origin, because object-position establishes static placement of content inside the element rather than defining the pivot point for geometric transforms. That means you can combine these properties: use object-position to choose a focal point and use transforms or animations to alter scale or motion around that content.

From a workflow perspective, object-position is handy for delivering consistent visual composition across breakpoints without changing markup or swapping art-directed image sources. It is animatable in many user agents, so designers can create smooth focal-point transitions (for example, panning across a photo). Because it only affects the painted area and not layout, be mindful of accessibility and content-critical design: important visual information may be cropped out if relying solely on object-position, so provide appropriate alternative text, consider art-directed source choices where necessary, and test across aspect ratios and screen sizes to ensure essential content remains visible.

Definition

Initial value
50% 50%
Applies to
Replaced elements
Inherited
No
Computed value
Specified value
Animatable
No
JavaScript syntax
object.style.objectPosition

Interactive Demo

Syntax

object-position: <position> 

Values

  • <position>Specifies the position of a object area (e.g. background image) inside a positioning area (e.g. background positioning area).

Example

<div class='gallery'>
<figure class='card'>
<div class='frame'>
<img src='https://picsum.photos/id/1069/1200/800' alt='Example image' class='pos-center'>
</div>
<figcaption>object-position: center</figcaption>
</figure>

<figure class='card'>
<div class='frame'>
<img src='https://picsum.photos/id/1069/1200/800' alt='Example image' class='pos-top-left'>
</div>
<figcaption>object-position: left top</figcaption>
</figure>

<figure class='card'>
<div class='frame'>
<img src='https://picsum.photos/id/1069/1200/800' alt='Example image' class='pos-bottom-right'>
</div>
<figcaption>object-position: right bottom</figcaption>
</figure>

<figure class='card'>
<div class='frame'>
<img src='https://picsum.photos/id/1069/1200/800' alt='Example image' class='pos-custom'>
</div>
<figcaption>object-position: 75% 25%</figcaption>
</figure>
</div>
/* Gallery layout */
.gallery {
    display: flex;
    gap: 16px;
    padding: 20px;
    background: #fafafa;
    align-items: flex-start;
}

.card {
    width: 200px;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
}

.frame {
    width: 200px;
    height: 150px;
    overflow: hidden;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #eee;
}

/* Make the image fill the frame and demonstrate object-position */
.frame img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover; /* required for object-position to have visible effect when aspect ratios differ */
}

/* Different object-position examples */
.frame img.pos-center {
    object-position: center;
}

.frame img.pos-top-left {
    object-position: left top;
}

.frame img.pos-bottom-right {
    object-position: right bottom;
}

.frame img.pos-custom {
    object-position: 75% 25%; /* x y using percentages */
}

figcaption {
    text-align: center;
    margin-top: 8px;
    font-size: 13px;
    color: #333;
}

Browser Support

The following information will show you the current browser support for the CSS object-position property. Hover over a browser icon to see the version that first introduced support for this CSS property.

Browser support for this property varies across browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!