How to use the "auto" value with clamp()

February 05, 2026

If you have tried the code below, you know it doesn't work:

.box { width: clamp(200px, auto, 400px);}

clamp() accepts only calculations, and values such as auto, min-content, and max-content aren't allowed. They make the entire value invalid.

With the new calc-size(), we can allow such values within clamp().

.box { width: calc-size(auto,clamp(200px, size, 400px)); }

The first argument of calc-size() can be any calculation or a sizing keywords. The second argument is a calculation where size refers to the first argument.

You can have endless combinations.

.box { width: calc-size(max-content,clamp(size, 70%, 600px));  width: calc-size(max-content,clamp(300px, 80%, 2*size));   width: calc-size(min-content,clamp(size + 50px, 100% - 40px, 700px));  width: calc-size(max-content,clamp(size,80%, 2*size)) }

⚠️ Limited support (Chrome-only for now)

Accueil - Wiki
Copyright © 2011-2026 iteam. Current version is 2.153.0. UTC+08:00, 2026-02-13 16:31
浙ICP备14020137号-1 $Carte des visiteurs$