A page with font sizes of 15, 17, 19, 22, and 27 has no rule, so the next size is a guess. A modular scale multiplies a base by the same ratio. This page writes --type-1 onward in rem, with the pixel size in a comment. The opening base is 16px, the ratio is 1.25, there are 6 steps, and the root is 16. The pixels are 16, 20, 25, 31.25, 39.0625, and 48.82813. In the stylesheet they are 1rem, 1.25rem, 1.5625rem, 1.95313rem, 2.44141rem, and 3.05176rem.
1.25 is a major third, a common text ramp: enough change that a heading is clearly a heading, not so much that step 6 becomes a poster. A ratio of 1.5 or 1.618 climbs faster and is easier to overshoot on a phone. The spacing scale is the same generator aimed at gaps, and it opens on a ratio of 2 because space and type should not be forced to share a number.
Fractional pixels are honest. 31.25px is what 16 times 1.25 three times actually is. Browsers render it. If you hate the fraction, round in your own stylesheet after you copy, and know that rounding breaks the ratio slightly. The comments are rounded to a readable number of decimals. They are still the computed sizes.
Base 16, ratio 1.25, 6 steps, root 16.
:root { --type-1: 1rem; /* 16px */ --type-2: 1.25rem; /* 20px */ --type-3: 1.5625rem; /* 25px */ --type-4: 1.95313rem; /* 31.25px */ --type-5: 2.44141rem; /* 39.0625px */ --type-6: 3.05176rem; /* 48.82813px */ }
Oddsock runs this in your browser. It is free, it does not upload the work, and it does not ask for an account.
1.25 keeps six steps in a practical range, from 16px to about 49px. 1.5 reaches poster sizes quickly. Try the words at the largest step before you commit.
Because 16 × 1.25 × 1.25 is 25, and the next step is 31.25. That is the scale. Rounding every step to a whole pixel is a second edit, and it loosens the ratio.
Rem is pixels divided by the root. At a root of 16, 16px is 1rem. The pixel comment is the design size either way.
No. Spacing opens at 4px and doubles. Type opens at 16px and multiplies by 1.25. Using one ratio for both makes either the type timid or the padding enormous.
It writes the custom properties. You still assign --type-6 to the display style and --type-1 to the body.