This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The contain
CSS property allows an author to indicate that an element and its contents are, as much as possible, independent of the rest of the document tree. This allows the browser to recalculate layout, style, paint, size, or any combination of them for a limited area of the DOM and not the entire page.
/* Keyword values */ contain: none; contain: strict; contain: content; contain: size; contain: layout; contain: style; contain: paint; /* Global values */ contain: inherit; contain: initial; contain: unset;
This property is useful on pages that contain a lot of widgets that are all independent as it can be used to prevent one widget's CSS rules from changing other things on the page.
Initial value | none |
---|---|
Applies to | all elements |
Inherited | no |
Media | all |
Computed value | as specified |
Animation type | discrete |
Canonical order | per grammar |
none
strict
contain: size layout style paint
.content
contain: layout style paint
.size
layout
style
paint
none | strict | content | [ size || layout || style || paint ]
Specification | Status | Comment |
---|---|---|
CSS Containment Module Level 1 | Candidate Recommendation | Initial definition |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 52 | ? | Yes
|
? | 40 | ? |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | 52 | 52 | ? | Yes
|
40 | ? | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/contain