Favorites

min() CSS Function

min()
CSS FunctionThis function is supported by all modern browsers.
Updated 21st November 2026

The min() function returns the smallest of a list of values, such as min(100%, 600px), which never gets wider than 600px.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The min() CSS function allows you to select the smallest value from a list of comma-separated expressions. It is particularly useful for creating responsive designs where you want a property to adapt dynamically but never exceed a certain value. The function can accept any combination of lengths, percentages, numbers, or even other CSS functions such as clamp() and max().

When applied, min() evaluates each value and applies the one that is numerically the smallest. This makes it ideal for situations where you want to constrain a property without using media queries. It works with various CSS properties, such as font-size, width, height, and margin.

Example 1: Responsive font size

p {
  font-size: min(4vw, 18px);
}

In this example, the paragraph text will scale with the viewport width, but it will never exceed 18px.

Example 2: Constraining a container

div.container {
  width: min(90%, 1200px);
}

Here, the container will take up 90% of the parent element’s width but will not grow larger than 1200px. This is particularly helpful when combined with div layouts in responsive designs.

Example 3: Combining with other functions

h1 {
  font-size: min(clamp(16px, 5vw, 40px), 36px);
}

This sets the heading size to the smaller of two values: a dynamically clamped range or a fixed maximum of 36px.

The min() function is widely supported in modern browsers and provides a clean, declarative way to manage responsive sizing without relying heavily on media queries.

Interactive Demo

050px100px150px200px250px
Demo Code
HTML Code
<div class="demo-track">
	<div class="demo-element"></div>
</div>
<div class="demo-scale"><span>0</span><span>50px</span><span>100px</span><span>150px</span><span>200px</span><span>250px</span></div>
CSS Code
.demo-track {
	width: 300px;
	height: 36px;
	background: #f4f4f4 repeating-linear-gradient(90deg, #b0b0b0 0 1px, transparent 1px 50px);
	outline: 1px solid #c5c5c5;
}
.demo-scale {
	display: grid;
	grid-template-columns: repeat(6, 50px);
	width: 300px;
	font-size: 11px;
	color: #666;
}
.demo-element {
	height: 100%;
	background: linear-gradient(90deg, #f72585, #b5179e);
	width: min(50%, 200px);
}

Syntax

min() = min( value1, value2, ... ) 

Values

  • value1, value2, ...A list of comma-separated values - where the lowest value is chosen. Required.

Example

<body>

<div class="responsive-box">
<p>This box uses <code>min(80%, 600px)</code>.</p>
<p>Resize your browser window to see it in action!</p>
</div>

</body>
body {
font-family: sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f2f5;
}

.responsive-box {
/* The logic: Use 80% width, but stop growing once 600px is reached */
width: min(80%, 600px);

background-color: #ffffff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
text-align: center;
border: 2px solid #007bff;
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS min() function. Hover over a browser icon to see the version that first introduced support for this CSS function.

This function is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.