keyword

fit-content — CSS reference

Clamps the available stretch-fit size between the min-content and max-content sizes when available space is definite. If the minimum exceeds the available space, overflow can remain.

Formal Syntax & Structure

css syntaxcss
fit-content

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS sizing and overflow lab</title><style>body {margin:0} .sample {background:#dcebe9;color:#182e32}#p{width:100px} #a,#b{font-size:0} span{display:inline-block;width:70px;height:20px} #a{width:fit-content} #b{width:50px}</style><body><div id="p"><div id="a" class="sample"><span></span><wbr><span></span></div><div id="b" class="sample"><span></span><wbr><span></span></div></div></body></html>
CSS Reference