Skip to content
OddsockLocal
Local
Minimum size (px)16
Maximum size (px)32
Narrow viewport (px)320
Wide viewport (px)1280
Minimum size (px)16
Maximum size (px)32
Narrow viewport (px)320
Wide viewport (px)1280
ReadyRuns in this browser. Nothing is uploaded.

How to use

  1. Type the size at the narrow width and the size at the wide width, in pixels.
  2. Type those two viewport widths. The wide one must be larger.
  3. Copy the clamp() into font-size, padding, gap, or width.
  4. Resize the browser past both widths and confirm the value stops.

What is CSS clamp()?

A heading that is 32px on a laptop and would overflow a phone needs a size that moves with the viewport and then stops. clamp() takes a minimum, a preferred value, and a maximum. This page computes the preferred value so the size is exactly the minimum at the narrow viewport and exactly the maximum at the wide one. From 16px to 32px between 320px and 1280px wide, the rule is clamp(16px, 10.66667px + 1.66667vw, 32px).

Read more

Check the arithmetic on a known width. The slope is (32 − 16) / (1280 − 320), which is 16/960. Times 100, that is the 1.66667vw term. At a 320px viewport, 1.66667vw is 5.33333px, and 10.66667 + 5.33333 is 16. At 1280px the same expression hits 32. Below 320 the clamp stays at 16. Above 1280 it stays at 32. That stop is the point. A raw vw value keeps growing on a huge monitor and shrinking on a tiny one.

The responsive-font page prints the same kind of formula and is framed as type. Use this page for any length: a gap, a padding, a width, a font-size. The wide viewport has to be larger than the narrow one, and the maximum size cannot be smaller than the minimum.

Use cases

  • A hero heading grows from 32px to 64px between a phone and a desktop width.
  • A page padding scales from 16px to 48px and stops, instead of becoming enormous on a wide monitor.
  • A card max-width eases across a breakpoint range without a pile of media queries.
  • A designer checks the formula at 320 and 1280 before pasting it.
  • A component uses one clamp for the title and a separate clamp for the gap under it.

16px on a phone, 32px on a desktop

Minimum 16, maximum 32, narrow viewport 320, wide viewport 1280.

clamp(16px, 10.66667px + 1.66667vw, 32px). At 320px wide the preferred value is 16px. At 1280px wide it is 32px.

Why use Oddsock

Oddsock runs this in your browser. It is free, it does not upload the work, and it does not ask for an account.

Related tools

Using this tool

The size stays at the minimum. Above the wide viewport it stays at the maximum. Between them it slides.