On this page
min()
Prev: `clamp()` | Up: math | Next: `minmax()`
Rel: math, Math & Sizing Functions Guide
Ref: MDN Web Docs — min()
Tags: #public #web #css #functions #math #tier/core
Syntax & Overview
min(100% - 2rem, 72rem) /* + max() */
Selects the smallest (or largest with max()) value from a comma-separated list.
Notes & Best Practices
- Replaces
width: 100%; max-width: 70ch;in one declaration:width: min(70ch, 100% - 2rem)also guarantees side gutters on narrow mobile viewports.
Example
.container {
width: min(72rem, 100% - 2rem);
margin-inline: auto;
}
Linked from
Related notes
- tuts/css/functions/math/clamp Linked here; links to this page; shared tags: #css, #functions, #math, #tier, #web
- tuts/css/functions/math/minmax Linked here; links to this page; shared tags: #css, #functions, #math, #tier, #web
- tuts/css/functions/math Linked here; links to this page; shared tags: #css, #functions, #math, #web
- tuts/css/functions/math_and_sizing_functions Linked here; shared tags: #css, #functions, #web
- tuts/css/functions/math/calc shared tags: #css, #functions, #math, #tier, #web
- tuts/css/functions/math/repeat shared tags: #css, #functions, #math, #tier, #web
- tuts/css/functions/color/color-mix shared tags: #css, #functions, #tier, #web
- tuts/css/functions/color/light-dark shared tags: #css, #functions, #tier, #web
- tuts/css/functions/color/linear-gradient shared tags: #css, #functions, #tier, #web
- tuts/css/functions/color/oklch shared tags: #css, #functions, #tier, #web