liveBook · Manning

Clipping

As explained in Math for Web Design

Clamping is the technique of restricting a value to a specified lower and upper limit.

A font size that grows with the viewport can become unreadably small on a phone or oversized on a wide screen. Clipping a numeric value—also called clamping—keeps it between a lower and an upper limit. The value can still change smoothly between those limits. section 3.2.3 section 8.2.2

In CSS, `clamp(MIN, VAL, MAX)` uses the preferred value when it is within range, the minimum when it falls below range, and the maximum when it rises above range. The equivalent calculation is `max(MIN, min(VAL, MAX))`. Use `min()` or `max()` alone when you need only one boundary. section 3.2.3

Keep a heading within readable limits

Set `font-size: clamp(32px, 8vw, 64px)`. At a 500px viewport width, `8vw` is 40px, so the heading uses 40px. At 1000px, `8vw` is 80px, so the heading stops at 64px. If the preferred size drops below 32px, the heading stays at 32px. section 3.2.3

Derive a fluid container width

Suppose a container should measure 400px at a 500px viewport and 800px at a 1000px viewport. Its slope is `(800 − 400) / (1000 − 500) = 0.8`, giving a preferred width of `80vw`. Use `width: clamp(400px, 80vw, 800px)` to preserve that growth while capping both ends. section 6.5.3

The same boundary-setting idea applies when a custom slider converts cursor positions into numeric values: its value must stay within predefined limits. This is different from visual clipping with CSS `clip-path`, which hides parts of an element outside a shape rather than limiting a number. section 13.2 section 10.4.1

How Math for Web Design covers it

How deep it goes
Defines the CSS constraint, shows its min/max equivalent, and derives a bounded width from two viewport measurements; leaves slider implementation undeveloped.
Examples
Uses a viewport-scaled hero heading, a bounded container width, and cursor-to-value conversion in a custom slider.
What it assumes
Assumes familiarity with CSS declarations and viewport units, but works through the slope calculation for a custom fluid width.
What you can do after
Apply it via CSS `clamp()` to make fluid sizes respect minimum and maximum values.
How it connects
Connects value bounds to fluid typography, viewport units, linear equations, responsive layouts, and custom sliders.

Also explained in

Compare how 3 books explain clipping →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Math for Web Design. The section links point to the parts of the book it draws on.