coderef

object-fitBaseline · Widely available

The object-fit CSS property sets how images, videos, and other replaced elements are scaled within their container.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jan 15, 2020. Widely available since Jul 15, 2022.

Browser support

DesktopChrome
1–31Not supported
32+Supportedsince Jan 14, 2014
Current: 155
Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154
Firefox
1–35Not supported
36+Supportedsince Feb 24, 2015
Current: 157
Safari
1–9.1Not supported
10+Supportedsince Sep 20, 2016
Current: 27
MobileChrome Android
18–31Not supported
32+Supportedsince Jan 15, 2014
Current: 155
Firefox Android
4–35Not supported
36+Supportedsince Feb 27, 2015
Current: 157
Safari iOS
1–9.3Not supported
10+Supportedsince Sep 13, 2016
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: object-fit.

Feature detection

CSS · check before using
@supports (object-fit: initial) {
  /* styles that rely on object-fit */
}

/* or in JavaScript */
if (CSS.supports("object-fit", "initial")) {
  // use it
}

Sub-features

Support for each part of the feature (6). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
object-fit32793610323610
object-fit.contain32793610323610
object-fit.cover32793610323610
object-fit.fill32793610323610
object-fit.none32793610323610
object-fit.scale-down32793610323610