Testing

Object-fit: Browser Support, Values, Use Cases

The CSS object-fit property works in Chrome 32+, Edge 79+, Firefox 36+, Safari 10+, Opera 19+, and Samsung Internet 4+. See full browser support and values.

Author

Prince Dewani

May 6, 2026

The CSS object-fit property is a W3C CSS Images Module Level 3 property that controls how a replaced element such as an img, video, or iframe is resized to fit its content box. It works in Chrome 32+, Edge 79+, Firefox 36+, Safari 10+ on macOS and iOS, Opera 19+, and Samsung Internet 4+, while Internet Explorer never shipped support.

This guide covers what object-fit is, the browsers that support it, the property values, the use cases, and the known issues.

What is object-fit?

object-fit is a CSS property defined by the W3C in CSS Images Module Level 3. It tells the browser how to size a replaced element, such as an img or video, inside its content box. The five allowed values are fill, contain, cover, none, and scale-down.

Which browsers does object-fit support?

object-fit ships by default in every modern engine. The Web Platform Baseline marks it as Widely Available across Chromium, Gecko, and WebKit, with Internet Explorer the only major engine that never added the property.

Loading browser compatibility data...

object-fit compatibility in Chrome

Chrome supports object-fit from Chrome 32 on Windows, macOS, Linux, ChromeOS, and Android. Chrome 4 to 31 did not support the property at all, so any image or video in those builds always uses the default fill behavior and stretches to its container.

object-fit compatibility in Edge

Microsoft Edge supports object-fit fully from Edge 79 on Windows, macOS, and Linux through its Chromium pipeline. Edge Legacy 16 to 18 only supported object-fit on img elements; video tags fell back to the default fill behavior. Edge 12 to 15 did not support the property at all.

object-fit compatibility in Firefox

Firefox supports object-fit from Firefox 36 on Windows, macOS, Linux, and Android. Firefox 2 to 35 did not parse the property, so legacy builds drop the declaration silently and the replaced element stretches to fill its box.

object-fit compatibility in Safari

Safari supports object-fit fully from Safari 10 on macOS and from Safari 10 on iOS and iPadOS. Safari 7.1 to 9.1 on macOS and Safari 8 to 9.3 on iOS had partial support that worked on img tags but not on video. Safari 3.1 to 7 on macOS and Safari 3.2 to 7.1 on iOS did not support it.

object-fit compatibility in Opera

Opera supports object-fit from Opera 19 on Windows, macOS, and Linux through its Blink engine. Opera Mobile picked up support from Opera Mobile 11 on Android, while Opera 9 to 18 dropped the property as unrecognized syntax.

object-fit compatibility in Samsung Internet

Samsung Internet supports object-fit from Samsung Internet 4 on Galaxy phones and tablets through its Chromium base. Every shipped Samsung Internet build from 4 onward applies object-fit to img, video, and other replaced elements identically to desktop Chrome.

object-fit compatibility in Android Browser

Modern Android WebView and Chrome for Android support object-fit from Chrome 32 forward. The legacy stock Android Browser (2.1 to 4.4) did not support the property; the 4.4.3 and 4.4.4 builds shipped a WebView that picks up object-fit through the underlying Chromium update.

object-fit compatibility in Internet Explorer

Internet Explorer 5.5 through Internet Explorer 11 never added support for object-fit. Microsoft has retired Internet Explorer, so any legacy intranet pages that still need image cropping have to use a polyfill such as object-fit-images on img elements or fall back to a CSS background-image with background-size: cover.

Note

Note: object-fit behaves differently across Edge Legacy, partial-support Safari builds, and modern engines. Test it on real browsers and OS with TestMu AI. Try TestMu AI free!

What are the object-fit property values?

object-fit accepts five keyword values that decide how the replaced element scales inside its content box. The default is fill, but most production code uses cover or contain to preserve the aspect ratio of images and videos.

  • fill (default): Stretches the media to fill the entire content box. The aspect ratio is ignored, so a wide photo placed in a square box looks squashed. Use it when the source already matches the box.
  • contain: Scales the media to fit fully inside the box while keeping the original aspect ratio. Empty letterbox or pillarbox bars appear when the ratios differ. Use it for product thumbnails where every pixel must be visible.
  • cover: Scales the media to fill the box and crops any overflow, keeping the aspect ratio. No empty space appears but pixels at the edges are cut. Use it for hero images, avatars, and card cover photos.
  • none: Keeps the media at its intrinsic size. The box may show only a slice of the image or surround it with empty space. Pair it with object-position to control which slice is visible.
  • scale-down: Picks the smaller result between none and contain. Small images stay at their natural size while large ones shrink to fit. It is the safest pick for mixed asset libraries with unpredictable sizes.

Pair any value with object-position to shift the scaled media inside the box. The default is 50% 50%, which centers the content; object-position: top keeps the top of a portrait image visible after a cover crop.

/* 1. Cover: fill the box and crop overflow. Useful for hero images and avatars. */
.card-image {
    width: 320px;
    height: 200px;
    object-fit: cover;
    object-position: center;
}

/* 2. Contain: fit the whole image inside the box, even if bars appear. */
.product-thumb {
    width: 200px;
    height: 200px;
    object-fit: contain;
    background: #f5f5f5;
}

/* 3. None: keep the image at its intrinsic size and crop with the box. */
.fixed-icon {
    width: 64px;
    height: 64px;
    object-fit: none;
    object-position: 0 0;
}

/* 4. Detect support before shipping a fallback. */
@supports not (object-fit: cover) {
    .card-image {
        background-size: cover;
        background-position: center;
    }
}
...

What are the use cases of object-fit?

object-fit replaces a stack of older techniques such as background-image hacks, JavaScript resize scripts, and absolute-positioned img wrappers. Most teams adopt it on responsive media grids, product galleries, and any layout where a fixed box has to display arbitrary user-uploaded content.

  • Responsive hero images: Use object-fit: cover with object-position: center on a full-width hero img so the artwork fills the viewport at every screen size without distortion.
  • Avatars and profile pictures: Square avatar boxes with object-fit: cover crop arbitrary user uploads to a circle without forcing users to pre-crop their photos.
  • Product thumbnail grids: object-fit: contain shows every product photo in full without cropping, which is critical for ecommerce where the entire item must be visible.
  • Video player layouts: Apply object-fit: cover to a video tag so a 16:9 stream fills a 4:3 player on a tablet without black bars on the sides.
  • Card layouts and CMS content: Mixed image dimensions from a CMS render uniformly when each card image has object-fit: cover and a fixed width and height, instead of breaking the grid layout.
  • Replacing background-image hacks: object-fit on a real img tag preserves SEO, alt text, and lazy-loading attributes that a CSS background-image cannot provide.
...

What are the known issues with object-fit?

object-fit ships widely but still surprises teams that move from a JS-based crop to a pure CSS one. Most of the bugs come from missing dimensions on the img tag, video-tag gaps in Edge Legacy, and IE 11 traffic that needs a polyfill.

  • No effect without a sized box: object-fit only changes how content fits an already sized box. An img with no width or height ignores the property and renders at its intrinsic size.
  • Edge Legacy video gap: Edge 16 to 18 honored object-fit on img but not on video, so a video tag in those builds always renders with the default fill stretch.
  • Internet Explorer has no support: IE 5.5 to 11 drop the declaration entirely. Use the object-fit-images polyfill for img tags or swap to a background-image fallback for IE traffic.
  • iOS 9 video glitch: Safari iOS 8 to 9.3 supported object-fit on img only. A video tag with object-fit: cover in those builds stretches to fill the box instead of cropping.
  • Conflicts with intrinsic sizing: Setting both width: 100% and height: auto on an img with object-fit: cover removes the cropping effect, because the box auto-resizes to the image. Pin both dimensions or use aspect-ratio.

In my experience, the trap that bites teams hardest is shipping a card grid with object-fit: cover and forgetting that one CMS template missing the height attribute on its img tag will quietly fall back to fill on every card it renders.

Citations

All object-fit version numbers and platform notes in this guide come from these primary sources:

Author

Prince Dewani is a Community Contributor at TestMu AI, where he manages content strategies around software testing, QA, and test automation. He is certified in Selenium, Cypress, Playwright, Appium, Automation Testing, and KaneAI. Prince has also presented academic research at the international conference PBCON-01. He further specializes in on-page SEO, bridging marketing with core testing technologies. On LinkedIn, he is followed by 4,300+ QA engineers, developers, DevOps experts, tech leaders, and AI-focused practitioners in the global testing community.

Open in ChatGPT Icon

Open in ChatGPT

Open in Claude Icon

Open in Claude

Open in Perplexity Icon

Open in Perplexity

Open in Grok Icon

Open in Grok

Open in Gemini AI Icon

Open in Gemini AI

Copied to Clipboard!
...

3000+ Browsers. One Platform.

See exactly how your site performs everywhere.

Try it free
...

Write Tests in Plain English with KaneAI

Create, debug, and evolve tests using natural language.

Try for free

Frequently asked questions

Did you find this page helpful?

More Related Hubs

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests