contain
Widely availableSince 202297% of users
Tells the browser that an element and its content are independent of the rest of the page. This allows the browser to optimize rendering because it knows changes inside won't affect anything outside.
What's modern
From web-features, MDN's browser data and our snippets, checked dailyModernIn every major browser since March 2022. Widely available since September 2024.
Newer parts of contain
inline-sizeBaseline Sept 2022, Widely Mar 2025styleBaseline Jul 2022, Widely Jan 2025
See how modern your own CSS is.Check your CSS →
Quick facts
- Initial value
none- Inherited
- No
- Applies to
- all elements
- Animation type
- notAnimatable
Quick example
.isolated-widget {
/* Prevents changes inside from affecting the rest of the page layout */
contain: layout paint;
}Values
nonestrictcontentsizeinline-sizelayoutstylepaintcontain browser support
BaselineWidely availableThis feature is well established and works across many devices and browser versions. It has been available across browsers since 2022.Safe to use without fallbacks.
Usage97%of people can use this3% use a browser without it.
Browsers
52+
69+
15.4+
79+Mobile
52+Android
79+Android
15.4+iOS