concept

Inline size containment — CSS reference

Inline-size containment removes descendant contributions to intrinsic sizing in the inline axis only. It does not suppress block-axis content sizing. A shrink-to-fit inline block can collapse in width while retaining the content height.

Formal Syntax & Structure

css syntaxcss
contain: inline-size;

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>inline-size-containment</title><style>body{margin:0}#a{padding:8px;background:rgb(232,237,241);color:rgb(0,0,0);box-sizing:border-box}#box{display:inline-block;contain:inline-size}</style><body><section id="box"><div id="child" style="width:100px;height:60px">Content</div></section></body></html>
CSS Reference