Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Functions

The min() function

Reference for the CSS min() function: how it picks the smallest of several values, why it works as a maximum size, with responsive width examples.

The min() function takes a comma-separated list of values and resolves to the smallest one. Because the browser evaluates it during layout, you can compare values in different units, such as a viewport percentage against a fixed length.

The name can mislead. Using min() for a width means "never wider than the smallest of these", so it behaves like a maximum size.

CSS
.container {
  width: min(90%, 60rem);
}

Try it

A width that stops growing

Syntax

CSS
min( <calc-sum>#{2,} )
min(50vw, 400px, 100% - 2rem)

Syntax and arguments

Part Description
Arguments One or more comma-separated values or calculations. At least one is expected; with a single value it returns that value.
Types All arguments must resolve to compatible types (all lengths, all numbers, and so on). Percentages mix with lengths where the property allows.
Arithmetic Each argument may contain + - * / without writing calc(): min(100% - 2rem, 50rem).
Result The smallest argument after resolution.

Usage notes

  • min() = upper bound. Use it to cap something. For a lower bound use max(); for both, clamp().
  • No calc() needed inside, but extra nested parentheses are fine.
  • Percentages need a reference. In width, % refers to the container; if the container's width depends on the content, the percentage may behave as auto for intrinsic sizing.
  • Great for responsive padding and widths without media queries, such as padding-inline: min(5vw, 3rem).
  • Mixed units are the point: min(100vw, 100%), min(10vh, 4rem).
  • max-width often does the same job more readably; min() shines when the result feeds another property or calculation.
  • Accessibility: do not use it to cap font-size in ways that prevent zoom. Combine relative units such as rem with min().

Browser support

Supported in all current major browsers.