Interview Question

What is contain property?

contain limits selected layout, style, size, or paint effects to a subtree.

💡 Concept ✅ Quick Revision 🎨 CSS

Answer

The contain property declares that an element’s subtree is independent in selected ways. β€’ Containment types include size, inline-size, layout, style, and paint. β€’ Containment can limit how much of the document needs layout or painting work. β€’ Incorrect containment can clip painting or change sizing behavior.

💡 Simple Example

.widget { contain: layout paint; }

⚡ Quick Revision

contain limits selected layout, style, size, or paint effects to a subtree.