On this page
  1. clamp()
  2. Syntax & Overview
  3. Notes & Best Practices
  4. Example

clamp()

Prev: `calc()` | Up: math | Next: `min()`
Rel: math, Math & Sizing Functions Guide
Ref: MDN Web Docs — clamp()
Tags: #public #web #css #functions #math #tier/core


Syntax & Overview

clamp(1.25rem, 1rem + 2vw, 2.5rem)

Clamps a fluid preferred value between a minimum floor and maximum ceiling.

Notes & Best Practices

Example

h1 { font-size: clamp(1.75rem, 1.2rem + 2.5vw, 3.25rem); }
.section { padding-block: clamp(2rem, 5vw, 5rem); }

Linked from

Related notes