Build a whole type scale in one go: pick a body size, a ratio, and how many steps you want above and below it, and get a block of CSS custom properties where every step is its own fluid clamp(). The distinctive part is the two ratios. Most generators take one, and one is usually wrong somewhere — a 1.618 golden-ratio scale that looks striking on a desktop puts a 180px heading on a phone that has nowhere to put it. Setting a tighter ratio for small screens and a looser one for large means the relationships between your sizes change with the viewport, not just the sizes themselves. Every step uses rem bounds, so the scale still responds to a reader who has increased their default text size. If you only need one fluid value rather than a whole scale, the CSS Clamp Generator does that.
| Ratio | Name | Character |
|---|---|---|
| 1.125 | Major second | Very subtle — dense interfaces |
| 1.2 | Minor third | A safe default for UI |
| 1.25 | Major third | Clear hierarchy, still compact |
| 1.333 | Perfect fourth | Editorial, generous |
| 1.5 | Perfect fifth | Strong contrast |
| 1.618 | Golden ratio | Dramatic — needs a large screen |
A set of sizes where each is the previous one multiplied by a fixed ratio. It borrows from musical intervals — 1.5 is a perfect fifth, 1.333 a perfect fourth — and the point is that the sizes relate to each other by a consistent rule, which reads as deliberate rather than arbitrary.
Because a ratio that works on a desktop usually does not work on a phone. Five steps up from 16px at a 1.618 ratio is over 180px — fine on a large screen, impossible on a 375px-wide one. A tighter ratio at the narrow end keeps the scale usable, and because each step is a clamp, the ratio itself changes smoothly with the viewport.
1.2 or 1.25 for most interfaces — enough contrast to establish hierarchy without dominating the page. 1.333 and up suits editorial layouts with large display headings. 1.618 is dramatic and needs room. The preview shows the effect immediately, which is a better guide than the numbers.
So the scale respects the reader's own font setting. A scale built from px or bare vw units ignores it entirely, which means someone who has increased their default text size gets no benefit — an accessibility failure under WCAG 1.4.4, not a stylistic question.
Paste the :root block into your stylesheet and reference the steps by name — font-size: var(--step-2) for a heading, var(--step-base) for body text. Naming the steps is what makes a scale maintainable; changing the ratio later then updates everything at once.
Yes, and it is worth doing. A spacing scale built on the same ratio makes margins and padding relate to the type, which is most of what makes a layout feel coherent. Change the prefix to something like space and use a smaller base.
A modular scale multiplies each step by a fixed ratio, so sizes relate to one another the way musical intervals do rather than being picked individually — which is what makes a set of headings look deliberate instead of arbitrary. This generator takes two ratios rather than one, and that is the point of it. A single ratio that looks striking on a desktop is wrong on a phone: at 1.618, five steps above a 16px body gives a heading of over 180px, which no phone can hold. Applying a tighter ratio at the narrow end and a looser one at the wide end means the scale itself becomes fluid, not just each individual size. Every step is then emitted as its own clamp(), computed from its own pair of endpoints, with rem bounds so the whole scale still responds to the reader's font setting — a scale built from px or bare vw units ignores it completely and fails WCAG 1.4.4. The output is a block of CSS custom properties rather than loose values, because a scale is only useful if the steps are referenced by name; the prefix is sanitised into a legal custom property name, since a space or a stray character silently invalidates the declaration and the variable simply resolves to nothing.