Layout
Spacing that has a reason
A small spacing scale, a clear grouping rule, and a more useful way to judge the gaps.
Spacing is how a page explains which things belong together. A heading near a paragraph forms one group. A larger gap before the next heading tells the reader that a new idea is starting.
Use fewer values
Start with a short sequence such as 4, 8, 12, 16, 24, 32, 48 and 64 pixels. The exact sequence matters less than using it consistently. If every margin is a different value, it becomes difficult to see why one region feels tighter than another.
:root {
--space-1: .5rem;
--space-2: 1rem;
--space-3: 1.5rem;
--space-4: 2rem;
--space-5: 3rem;
}Use the smaller steps inside a component. Use the larger ones between components and sections. You should be able to explain why a gap changes.
Think inside, then outside
A label should sit closer to its own input than to the next field. A heading should usually sit closer to the text below it than to the previous section. This simple relationship often does more work than a border or a background colour.
| Relationship | Try first |
|---|---|
| Label to value | 8px |
| Heading to description | 12–16px |
| Between related cards | 24px |
| Between major sections | 48–64px |
Let the layout carry the gaps
Use gap for a row or grid of related items. This keeps the spacing in one place and avoids the familiar problem of the last item having an unwanted extra margin.
.cards {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 1.5rem;
}On a narrow screen, switch to a single column before the text starts to feel squeezed. Shrinking every gap is rarely enough to rescue a layout designed around three columns.
Try this: blur a screenshot slightly, or step back from the screen. You should still be able to see the main groups. If everything merges into one block, give the sections more separation.
Make exceptions deliberately
A curved letter can look as if it sits farther from an edge than a straight one. A large headline may need a small optical adjustment. It is fine to make that adjustment; document it as an exception rather than adding a new spacing token for a single case.
A good spacing system removes routine decisions so there is more attention left for the places that really need it.