Typography, Color Spaces & Vector Craft
Using Spacing Tokens and Grouping Ratios to Clarify Complex Pages
When a procedure, warning, and reference table sit close together, readers can lose track of which instructions belong to which heading. Start with a 4 px spacing grid, give a heading 8 px to its body, and use 32 px between peer sections. Measure the rendered gaps and test the grouping at narrow widths with real content.
Measure where the page changes subject
Start with a page that contains a procedure, a warning, and a reference table. Mark the blocks that answer the same question. A heading belongs with its first paragraph. A table caption belongs with its table. A warning about one action belongs beside that action. Gestalt proximity describes the tendency to perceive nearby elements as a group, as demonstrated in experiments with dot patterns. Use the shortest gaps for relationships the reader needs to recognize on sight. A shared left edge, an enclosing border, and repeated type styles also influence which elements appear to belong together.
Open the page at a fixed viewport width and wait for the text to settle. In the browser inspector, record the bottom edge of each heading box, the top edge of its first body box, and the edges at each transition between sections. Subtract the earlier bottom coordinate from the later top coordinate. With a heading ending at y = 120 and its paragraph starting at y = 136, the gap is 16 CSS px. If the paragraph ends at y = 208 and the next heading starts at y = 224, that gap is also 16 px. The between-group gap divided by the within-group gap is 1:1, so spacing gives both relationships equal weight.
Assign a spacing token to each relationship
Use a 4 px module with values of 4, 8, 12, 16, 24, and 32 px. Treat these as starting values at the default root text size. Name tokens by their job, such as --space-heading-body and --space-section. Give each stack one owner for the gap between its children. A grid or flex stack can apply gap, with default block margins reset on its direct children. A stack that needs multiple distances can nest a heading and body inside one group, then apply the section gap between groups.
| Relationship | Start at | Measure between | Adjust when |
|---|---|---|---|
| Caption to table | 4 px | Caption bottom edge and top of table grid | Try 8 px if a wrapped caption crowds the table header. |
| Heading to first body block | 8 px | Heading box and body box | Try 12 px when a larger heading crowds the first line. |
| Paragraphs in one section | 12 px | Adjacent paragraph boxes | Try 16 px if long paragraphs are hard to distinguish. |
| Panel inset | 16 px | Inner border edge and content edge | Try 12 px inline if wrapping makes the panel hard to read. |
| Nested topic boundary | 24 px | Previous group and next subheading | Check that it reads as a smaller transition than a peer section. |
| Peer section boundary | 32 px | Adjacent section boxes | Try 24 px in a compact layout and recheck heading attachment. |
In the measured example, move the first body block to y = 128. Its 72 px height puts its new bottom at y = 200. Start the next heading at y = 232, giving a 32 px boundary and a 4:1 ratio. This ratio is a layout starting point. If an 8 px heading gap feels cramped after the heading wraps, 12 px against 32 px still gives about 2.7:1. Judge the relationship again with the longest heading and the shortest body block.
Separate panel padding from the gap between panels
Assign inner padding to the panel and outer spacing to the parent stack. Measure padding from the inside edge of the border to the content edge, and measure the clear gap from border box to border box. These are separate distances in the CSS box model. Two panels with 16 px block padding and a 32 px stack gap have a 2:1 outer-gap-to-padding ratio. The schematic uses a zero-width border for the spacing arithmetic, with outlines drawn as reference lines. Across that boundary, the content edges are 16 + 32 + 16 = 64 px apart. With a 1 px CSS border on each panel, the content-to-content distance is 66 px.
On a 360 px viewport with 16 px page gutters, a full-width panel has a 328 px border box. Inside two 1 px borders and two 16 px inline insets, its content gets 294 px. Reducing only the inline inset to 12 px recovers 8 px for a long setting name and preserves the vertical grouping. If a code sample or table still exceeds that width, give the component a local horizontal scroll area and keep its caption with it. Test keyboard access to the scroll area and check that the page itself has no horizontal overflow.
If adjacent cards feel detached from their shared heading, check the padding on the first card and the heading gap together. An 8 px gap to a card edge plus 16 px of top padding and a 1 px border puts the first content 25 px below the heading box. Inspect the whole distance before changing either token.
Keep vertical rhythm through wrapped content
Set line height and block spacing on the same module where the type permits it. At the default root size, a 16 px body with a unitless line height of 1.5 gives 24 px lines. A 24 px heading with a line height of 28 px also fits the module. A one-line heading, 8 px gap, two body lines, and a 32 px section gap advance the next section start by 28 + 8 + 48 + 32 = 116 px. A third body line moves that start to 140 px. Both starts fall on the 4 px module when the first starts on it.
Use auto height for text blocks. The module governs the spacing of boxes and the nominal line heights. Fonts can place their baselines differently within those boxes, and borders, mixed inline sizes, and fractional values can shift a box edge. Diagnose a 2 px offset by inspecting the box model before changing the gap. If a table or embedded figure introduces an odd height, continue the usual section spacing after it. A compensating spacer that works with a single row count will drift when the table gains a row.
Verify the hierarchy on the rendered page
Take screenshots at 360 and 1024 CSS px with the same content and font settings. Repeat at 200% browser zoom and record the resulting viewport width in CSS pixels. In each view, ask a colleague unfamiliar with the page to point to the step that owns a warning and locate a named reference value without using search. Compare a baseline and a revised layout with equivalent tasks. If two colleagues can help, reverse the order for the second person so the revised page gets less of an advantage from practice. Record wrong associations and time to the first correct answer separately. Use the results to decide which boundary needs adjustment.
- Measure heading-to-body and peer section gaps at both widths. Record the outer gap divided by the inner gap and investigate equal or reversed gaps.
- Check a wrapped heading, a two-line caption, and a warning immediately after a step. Verify that each still reads with its own content.
- Measure the panel inset and the gap between adjacent panel edges. If its gap looks larger than the token, check for a child margin, parent gap, or border included in the measurement.
- At 200% zoom, check for clipped text and make sure keyboard focus stays visible as you move through any scrollable table or code sample.
- Record the two viewport widths, the final token values, and the reason for any component exception in the studio notes.