CKTIS / CSS
object-position — positioning image content
The object-position property aligns the content of a replaced element, such as img, inside its content box. It lets you select the visible area when cropping without moving the element itself in the layout.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
object-position: <position>;
/* Examples */
object-position: center;
object-position: 25% 75%;
object-position: right 10px bottom 20px;object-position positions the content of a replaced element, such as img, inside its content box. Its initial value is 50% 50%; the property is inherited. object-fit determines the content size, while object-position determines its alignment—not the element's position in the layout.
The <position> type accepts left, right, top, bottom, center, lengths, and percentages. In a pair of numeric values, the first controls the horizontal axis and the second the vertical axis. A single left means left center. The form right 10px bottom 20px specifies offsets from the named edges.
A percentage aligns a point in the content with the corresponding point in the box: 100% 50% aligns right edges and vertical centers. On each axis, the offset from the start is (box size - object size) × percentage. When cropping, the difference can be negative. If the sizes match, changing the percentage on that axis produces no displacement.
Content outside the box is clipped; uncovered areas show the element's background. In the example, cover preserves the image's aspect ratio, and right center leaves its blue half visible. This property does not replace background-position, which positions background images.
Examples
<!doctype html>
<meta charset="utf-8">
<title>object-position</title>
<style>
img {
display: block;
width: 120px;
height: 120px;
object-fit: cover;
object-position: right center;
}
</style>
<img alt="Blue square" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='120' viewBox='0 0 240 120'%3E%3Cpath fill='red' d='M0 0h120v120H0z'/%3E%3Cpath fill='blue' d='M120 0h120v120H120z'/%3E%3C/svg%3E">Result
A 120 × 120 CSS-pixel blue square; the red half is clipped.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.