On this page
Whitespace tells people which elements belong together before they read a label. A cramped label can appear attached to the wrong field; an oversized card gap can make related metrics feel unrelated. A spacing system makes these relationships deliberate instead of letting each component accumulate arbitrary margins.
Start with relationships, then choose units
An eight-point grid is a useful foundation because common distances such as 8, 16, 24 and 32 pixels form a small, memorable vocabulary. It is not a requirement that every visible measurement be divisible by eight. Spacing relationships matter more than arithmetic purity, especially around text, icons and compact controls.
Use the px-to-rem converter to translate initial spacing values into relative units. With a 16-pixel root size, 8 pixels becomes 0.5rem and 24 pixels becomes 1.5rem. Confirm the actual root assumptions in your implementation instead of treating the conversion as universal.
Start with one representative screen containing a page heading, a form group and a card list. Identify the distances that distinguish those relationships. The aim is not to snap the screenshot to a decorative grid; it is to create a repeatable hierarchy that works when content changes.
Build a small scale with deliberate exceptions
A practical initial scale might contain 4, 8, 12, 16, 24, 32, 48 and 64 pixels. The four-pixel half-step supports tight icon-label pairs and compact controls without forcing every small relationship into an eight-pixel gap. Add a value only when a repeated need cannot be expressed well with the existing scale.
Distinguish spacing tokens from component dimensions. A 44-pixel control height, a one-pixel border and a 20-pixel icon do not invalidate an eight-point spacing approach. Control dimensions must accommodate content and interaction; spacing values describe the space around and between those objects.
Name the scale consistently, then apply it through layout roles. A small space can serve icon-label separation while a larger space separates sections. The introduction to design tokens explains how shared values reduce accidental variation. Avoid creating a different named token for every one-off gap before the underlying pattern is understood.
For a first pass, write down a few explicit defaults:
- Use 8 pixels between closely related label content.
- Start with 16 pixels between ordinary controls in a group.
- Try 24 pixels of padding inside medium cards.
- Use 32 or 48 pixels between distinct page sections.
These are working hypotheses. Test them against the density and content of your interface rather than applying them as a universal visual standard.
Encode hierarchy with proximity and rhythm
The essential rule is within-group spacing should usually be smaller than between-group spacing. A field label belongs closer to its input than the next field label. A card title belongs closer to its description than to a separate action area. Equal gaps everywhere erase this structure even if every gap uses the same scale.
Whitespace can replace some borders and containers. If a settings section already has a clear heading and generous separation, another card outline may add noise rather than clarity. Conversely, tightly packed dashboard panels may still need dividers because spacing alone cannot communicate their boundaries at the required density.
The Nielsen Norman Group explanation of proximity is useful when reviewing ambiguous groupings. Ask a colleague to identify groups without reading the copy. If they pair the wrong label and control, adjust distance before adding stronger color or heavier typography.
Use a vertical rhythm that allows content to grow. The space after a two-line heading should preserve its relationship to the following paragraph, not depend on a fixed heading height. Align containers and content starts, but do not force unrelated text blocks into equal heights simply to preserve a screenshot's baseline pattern.
Implement spacing at the layout boundary
Prefer container gaps for repeated siblings rather than distributing margins across every child. This makes ownership clearer and avoids accidental double spacing when components are composed. Padding belongs to the surface that contains the content; gap belongs to the layout that arranges the children.
:root {
--space-1: 0.25rem;
--space-2: 0.5rem;
--space-3: 0.75rem;
--space-4: 1rem;
--space-6: 1.5rem;
--space-8: 2rem;
}
.field-group {
display: grid;
gap: var(--space-4);
}
.field {
display: grid;
gap: var(--space-2);
}
.panel {
padding: var(--space-6);
}
.page-sections {
display: grid;
gap: var(--space-8);
}Read MDN's gap reference for behavior across layout modes. Be especially careful when a shared component includes external margins: the parent may already supply the appropriate gap. A reusable card should not silently decide how far away the next card sits.
Use optical adjustment when mathematical alignment looks wrong. An asymmetric icon may need a slight internal offset while its outer slot remains consistent. Record recurring exceptions rather than silently introducing arbitrary values throughout the page. The exception should solve a visible problem, not compensate for a poorly sized asset.
Adapt density without losing relationships
A spacious marketing page and a compact operations dashboard can share a scale without sharing every default. Define density modes through a few relationship changes: row padding, group gaps and panel padding. Keep the hierarchy intact rather than reducing every distance by the same percentage.
For example, a dense table may reduce row padding while retaining clear separation above its filter toolbar. Otherwise the toolbar and first data row can blur together. Preserve adequate interactive targets even when visual spacing is compact; density should not mean making controls difficult to select.
On smaller screens, reduce outer gutters before collapsing meaningful internal grouping. A card might move from 24 to 16 pixels of padding while preserving an 8-pixel label gap. The guide to responsive container widths helps distinguish page-level constraints from component-level spacing.
Test text enlargement and longer content. The WCAG text spacing guidance addresses user overrides that can expose clipped labels and fixed-height containers. Relative units alone do not prevent these failures; layouts must allow text to grow.
Finish with a spacing audit at several widths. Look for orphaned headings, inconsistent card padding, doubled margins and gaps that vanish when optional content is absent. Fix relationships rather than chasing isolated pixel differences. A coherent system should remain recognizable after every label in the prototype has changed.
Key takeaways
- Treat the eight-point grid as a useful vocabulary, not an absolute law.
- Keep related items closer than separate groups.
- Assign spacing ownership to the appropriate layout container.
- Allow documented optical exceptions and content-driven dimensions.
- Adapt density while preserving hierarchy, readability and usable controls.
Reach designers & developers at work
Put your product next to the tools people use every day. One sponsor per placement, no tracking pixels.
Become a sponsor