Master

Designing with the constraints

A layout is a set of decisions about what adapts and what holds. Naming those decisions in the file, rather than discovering them in the browser, is what makes a design maintainable, and it is also what makes it reviewable by anyone who has not written it.

What you will see

The reading width capped in characters, which adapts to any text size and any window, and is the one constraint that fixes reading everywhere.

About 1 min of reading

Try It

Put the scales in the file.

1

Type scale

:root { --s0: 1rem; --s1: 1.25rem; --s2: 1.56rem; --s3: 1.95rem; }

Before you run it, say out loud what it will print. Then open the answer.

What it prints
Four steps, each about a quarter larger. Every heading reads a step, never a raw size.
2

Spacing scale

:root { --sp1: 4px; --sp2: 8px; --sp3: 16px; --sp4: 32px; }

Before you run it, say out loud what it will print. Then open the answer.

What it prints
Four steps doubling. Any gap in the stylesheet is one of these, which is what makes two neighbours look intentional.
3

The measure

body { max-width: 68ch; }

Before you run it, say out loud what it will print. Then open the answer.

What it prints
The reading width capped in characters, which adapts to any text size and any window, and is the one constraint that fixes reading everywhere.

Data Flow

Scales drive every size.
1 Choose the fluid and fixed sizes
↓
2 Define a type scale
↓
3 Define a spacing scale
↓
4 Cap the reading measure
Why this works
The measure of a line

A line of text has a comfortable length, and past it the eye loses the next line. Capping the measure is a decision that fixes reading on every screen, and it is the one constraint worth applying everywhere.

Rhythm over the page

Vertical space between blocks from the same scale makes a page feel settled. That rhythm is a rule in the file, not a value tuned per section, and it is what makes a long page readable.

Examples

Decide what is fluid

Name which sizes scale with the window and which are fixed. Text and tap targets are fixed; columns and gaps usually scale. Writing that choice down stops the next editor guessing.

Type scale, not type sizes

A handful of steps, each a multiple of the one below, gives a page that looks related throughout. Six unrelated pixel sizes look like a design that was never designed.

Space on a scale too

Spacing from a small set of steps makes two elements next to each other look intentional. A page with 13, 17, and 22 pixel gaps has three numbers that no reader can explain.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← Reading what a page actually did
Previous Lesson
Reading what a page actually did