This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020.
The min() CSS function lets you set the smallest (most negative) value from a list of comma-separated expressions as the value of a CSS property value. The min() function can be used anywhere a <length>, <frequency>, <angle>, <time>, <percentage>, <number>, or <integer> is allowed.
width: min(50vw, 200px);
width: min(100vw, 4000px);
width: min(150vw, 100px);
<section class="default-example" id="default-example">
<div class="transition-all" id="example-element">
<img
alt="Firefox logo"
class="logo"
src="/shared-assets/images/examples/firefox-logo.svg" />
</div>
</section>
In the first above example, the width will be at most 200px, but will be smaller if the viewport is less than 400px wide (in which case 1vw would be 4px, so 50vw would be 200px). This technique uses an absolute unit to specify a fixed maximum value for the property, and a relative unit to allow the value to shrink to suit smaller viewports.
max(1, 2, 3) max(1px, 2px, 3px)
The min() function takes one or more comma-separated expressions as its parameter, with the smallest (most negative) expression value result used as the value.
The expressions can be math expressions (using arithmetic operators), literal values, or other expressions, such as attr(), that evaluate to a valid argument type (like <length>).
You can use different units for each value in your expression, if you wish. You may also use parentheses to establish computation order when needed.
auto had been specified.max() and other min() functions as expression values. The expressions are full math expressions, so you can use direct addition, subtraction, multiplication and division without using the calc() function itself.<length> syntax value.min() and max() values, or use min() within a clamp() or calc() function.<min()> =
min( <calc-sum># )
<calc-sum> =
<calc-product> [ [ '+' | '-' ] <calc-product> ]*
<calc-product> =
<calc-value> [ [ '*' | / ] <calc-value> ]*
<calc-value> =
<number> |
<dimension> |
<percentage> |
<calc-keyword> |
( <calc-sum> )
<calc-keyword> =
e |
pi |
infinity |
-infinity |
NaN
When using min() to set a maximum font size, ensure that the font can still be scaled at least 200% for readability (without assistive technology like a zoom function).
Another use case for min() is to set a maximum size on responsive form controls: enabling the width of labels and inputs to shrink as the width of the form shrinks.
Let's look at some CSS:
input,
label {
padding: 2px;
box-sizing: border-box;
display: inline-block;
width: min(40%, 400px);
background-color: pink;
}
form {
margin: 4px;
border: 1px solid black;
padding: 4px;
}
Here, the form itself, along with the margin, border, and padding, will be 100% of its parent's width. We declare the input and label to be the lesser of 40% of the form width up to the padding or 400px wide, whichever is smaller. In other words, the widest that the label and input can be is 400px. The narrowest they will be is 40% of the form's width, which on a smartwatch's screen is very small.
<form> <label for="misc">Type something:</label> <input type="text" id="misc" name="misc" /> </form>
| Specification |
|---|
| CSS Values and Units Module Level 4> # calc-notation> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
min |
79 | 79 | 75 | 66 | 11.1 | 79 | 79 | 57 | 11.3 | 12.0 | 79 | 11.3 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/min