fit-contentBaseline · Widely available
The fit-content CSS keyword expands a box as needed to fit its contents until the maximum size is reached, preserving the content's preferred aspect ratio.
Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Nov 2, 2021. Widely available since May 2, 2024.
Browser support
DesktopChrome
1–45Not supported
46+Supportedsince Oct 13, 2015
Current: 155Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154Firefox
1–93Not supported
94+Supportedsince Nov 2, 2021
Current: 157Safari
1–10.1Not supported
11+Supportedsince Sep 19, 2017
Current: 27MobileChrome Android
18–45Not supported
46+Supportedsince Oct 14, 2015
Current: 155Firefox Android
4–93Not supported
94+Supportedsince Nov 2, 2021
Current: 157Safari iOS
1–10.3Not supported
11+Supportedsince Sep 19, 2017
Current: 27How to use
This feature is Baseline widely available — use it freely, no fallback needed.
Example
Full syntax and examples are on MDN: fit-content.
Feature detection
CSS · check before using
@supports (height: fit-content) {
/* styles that rely on height: fit-content */
}
/* or in JavaScript */
if (CSS.supports("height", "fit-content")) {
// use it
}Documentation (MDN)
Specification
Sub-features
Support for each part of the feature (6). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| height.fit-content | 46 | 79 | 94 | 11 | 46 | 94 | 11 |
| max-height.fit-content | 46 | 79 | 94 | 11 | 46 | 94 | 11 |
| max-width.fit-content | 46 | 79 | 94 | 11 | 46 | 94 | 11 |
| min-height.fit-content | 46 | 79 | 94 | 11 | 46 | 94 | 11 |
| min-width.fit-content | 46 | 79 | 94 | 11 | 46 | 94 | 11 |
| width.fit-content | 46 | 79 | 94 | 11 | 46 | 94 | 11 |