function

Calc size() — CSS reference

Performs arithmetic on a sizing basis, including intrinsic keywords. The special size identifier represents the resolved basis within the calculation. Unlike calc(), the function can preserve intrinsic sizing semantics. Use a plain sizing declaration first as a fallback.

Formal Syntax & Structure

css syntaxcss
width: calc-size(max-content, size + 20px);

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>calc-size()</title><style>body{margin:16px;font:16px/1.5 system-ui;background:white;color:#172033} .demo{background:#dbeafe;box-sizing:border-box} button,select{font:inherit}#a{display:inline-block;width:max-content;width:calc-size(max-content,size + 20px)}#a span{display:block;width:120px}</style><body><div id="a" class="demo"><span>Content</span></div></body></html>
CSS Reference