seniorCSS
Explain the CSS Containment property (contain).
Updated Apr 28, 2026
Short answer
The contain property indicates that an element's subtree is independent of the rest of the page, allowing heavy performance optimizations.
Deep explanation
Values include layout, paint, size, and style, or the shorthand strict. It tells the browser that layout changes inside this element will not affect the outside world. This drastically reduces the scope of layout calculations when DOM mutations occur.
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro