Dustin Johnson ← Design Primitives
Design Primitive Reference · Part II · October 2026

Grid & Layout

Alignment — the edges and axes the eye draws through a screen whether or not anyone put them there, and the small set of lines a team can agree to put there on purpose.

I. Why Alignment Is Its Own Topic

Part I put blocks on a grid. This part is about what happens at their edges once they are placed: where text starts inside a box, where a button's right side stops, which line a number sits on. The grid can be perfect and the screen can still look off, because the eye doesn't read the grid. It reads edges.

The perception is the one Part I's §V named: the visual system infers continuous lines from aligned edges (the Gestalt principle of continuity) and uses those lines to decide what belongs together. Every left edge that lines up with another left edge makes an invisible guide. Every edge that almost lines up makes a guide and breaks it at the same time. That is what people mean when they say a screen "looks off" and can't say why. It is rarely one large mistake. It is usually two or three things that nearly align, each a few pixels from the line the eye expected.

Here is a screen of the kind that produces that complaint: a shipment detail page with a header and actions, a summary panel containing a nested panel of metrics, tabs, and a table. Every component on it came from a reasonable design system and is correct on its own. Look at it before turning the rails on.

Shipments / Ocean + railSHP-20418Rotterdam → Chicago · booked Sep 26
CarrierNordwave Lines
ModeOcean → rail
ETAOct 29
IncotermsCIF Chicago
Pieces1462 damaged
Gross weight18,166kg−254 vs booked
Volume62.4m³
$214,900Declared value
OverviewStopsDocumentsEvents
FacilityArrivedDwell hPiecesWeight kg
Rotterdam · Maasvlakte IISep 3018.514818,420
Montréal · Berth 62Oct 1311214818,420
Toronto · Rail yard 4Oct 176.2514618,166
Chicago · CorwithOct 29 est.———
Measuring… As found · Every part individually correct · Numbers measured live from the rendered page Look first, then show the rails. Solid lines are edges within 12px of another edge: the near-misses the eye notices without naming.

Nothing on that screen is broken in a way a code review would catch. The page header sits at the page margin. The summary card has the system's card inset. The metrics panel, being a panel, has the panel inset. The tabs carry the tab component's padding, and the table carries the table component's cell padding. Each of those values was chosen by someone thinking about one component. Put together, they produce six different left edges, three of them within eight pixels of each other, and a right edge that steps inward twice. Then there are the smaller things: numbers that don't line up in their columns, a metric whose label is below its value when its neighbors' labels are above, buttons aligned to the breadcrumb instead of the title.

That is why alignment needs its own treatment. Alignment is an emergent property of component insets, and no single component owns it. The card can't know what the table beside it does, and the tab bar can't know where the heading above it starts. Only a rule that applies across components — a small set of shared lines that every component agrees to put its content on — makes it reliable. Section XI audits this exact screen and fixes it; everything between here and there is the vocabulary that audit needs.

Alignment is also the one layout primitive that works at every scale. The same perception that notices a card two columns off the grid notices a table's first cell indented from the heading above it, an icon sitting a pixel low beside its label, and a column of figures whose decimal points wander. The rules in this part move down that scale: from the edges of blocks (sections II–V) to the content inside them (VI–VII), to the vertical axis (VIII), to the optical exceptions (IX), and to the lines that separate things (X).

The boundary, stated once: the column grid, column counts, gutters, margins, and container widths are Part I. The spacing scale, the three roles of space, and the nesting rule are Spacing & Density. This part is about edges and axes — which edge of a thing aligns, to which line, and on which axis. Spacing decides how far apart two things are. Alignment decides where each of them starts.

A screen that looks off rarely has one big mistake. It usually has five edges, each a few pixels from the line the eye expected.

II. Content Edge vs Container Edge

Every element on a screen has two left edges. Its container edge is the edge of its box: the border, the fill, the hover background. Its content edge is where its text or icon actually begins. For a heading they coincide. For a card they are separated by the card's inset. Most alignment arguments on a team are really arguments about which of the two edges should sit on the line, and they stay unresolved because nobody has said the rule out loud.

Part I's §VIII gave the first half: unboxed content aligns its text to the edge; boxed content aligns its box. What that leaves open is what counts as a box. The answer that settles nearly every case is this one: align whichever edge is visible at rest. A card with a border or a fill has a visible container edge whether or not anyone touches it, so its box goes on the line. A ghost button, a tab, a list row with a hover state, or an icon button has no visible box until the pointer arrives. At rest, the only thing the eye sees is the label, so the label goes on the line, and the box, when it appears, hangs outside it.

Documents
Commercial invoice84 KB
Bill of lading212 KB
Packing list37 KB
Box on the line · Wrong

The row's hover box and the ghost button's box sit on the edge, so their labels start 8 and 10px in. At rest, three left edges where the eye sees one column.

Documents
Commercial invoice84 KB
Bill of lading212 KB
Packing list37 KB
Label on the line · Box hangs · Right

Heading, row text, and the button's glyph share one edge; the overflow icon's dots share the right one. Hover boxes extend into the inset when they appear.

The reason for the rule is that a hover state is momentary and a misaligned label is permanent. Aligning the ghost button's box buys a correct edge during the half second the pointer is over it, and pays for it with a crooked label the rest of the time. The same logic covers the trailing side: an overflow icon button's three dots should line up with the right edge of the content above and below it, and its 24px hit area should extend past that edge.

The technique is a negative margin equal to the control's own horizontal inset, so the box moves out and the label stays on the line. Tie it to the inset token rather than writing a number, so the two can't drift apart:

.btn-ghost { padding-inline: var(--ghost-pad-x); /* 10px */ margin-inline-start: calc(-1 * var(--ghost-pad-x)); } /* label on the rail, box hangs */ .list-row { /* hover fill hangs, text stays */ padding-inline: 8px; margin-inline: -8px; } .toolbar > .btn-icon:last-child { margin-inline-end: calc(-1 * var(--icon-btn-pad)); }

Two cautions. A hanging box needs somewhere to hang: the parent's inset or the grid's gutter, never past a container that clips with overflow: hidden, or the focus ring gets cut off. And hanging is a rule for controls whose box is invisible at rest. A filled or outlined button has a visible box, so it doesn't hang; its box sits on the line like any card.

When the Container Edge Aligns

The other half of the rule covers the boxes that are always visible: cards in a grid, panels side by side, an input beside its button. Their container edges are what the eye sees first, so their container edges go on the line, and anything unboxed nearby aligns to those edges, not to the text inside them. The case that comes up most is the section heading over a row of cards. The pull is to indent the heading so it lines up with the card titles. That gives the region two left edges, with the heading floating between them.

Carriers on this lane
Nordwave LinesOcean · 31 sailings
Calder RailRail · 12 trains
Heading follows the content edge · Wrong

The heading lines up with the card titles, so the card borders stick out to its left. The region has no single edge.

Carriers on this lane
Nordwave LinesOcean · 31 sailingsBook
Calder RailRail · 12 trainsBook
Heading follows the box edge · Right

Heading and card borders share the outer line; everything inside the cards, including the filled button's box, shares a second.

That second line is the idea the rest of this part depends on. Once a box sits on the line, its inset creates an inner rail, and everything inside the box shares it: the card's title, its metadata, the first cell of a table placed inside it, the box of a filled button, the label of a ghost button. The inner rail is the box's version of the page's edge. Breaking it inside a card, with a table whose cells add their own padding or a nested panel that adds its own inset, produces the same ragged edge Part I showed at page level, only smaller.

Align what the eye can see when nothing is happening. Boxes that are always there sit on the line; boxes that appear only on hover hang outside it.

III. The Rails

A rail is a vertical line where content begins, shared by everything at one level of the layout. Material's older guidance called these keylines; print designers call them alignment lines or hang lines. Whatever the name, the useful claim is about quantity: a screen gets a small, countable number of rails, and each one has to be explained by a level of nesting the user can see.

Unplanned · Wrong

Each block brought its own offset. Nothing nests deeper than two levels, yet the screen has more than twice that many rails.

Planned · Right

Content rail, one inner rail for the cards, one more for the nested list. Every line answers "which level is this?"

The budget is short. The page margin is the distance from the region's edge to the first content; it is Part I's grid margin, and on most screens the content rail sits right on it. Unboxed text, card borders, table edges, and filled buttons share the content rail. Each level of visible nesting then adds exactly one inner rail: the inset of the first level of boxes, and, if there is a second level of nesting (an indented sub-list, a tree), one more. Most application screens need two rails and sometimes three. The right edge mirrors this with an outer and an inner right rail (section V).

RailSet byWho sits on it
Content railGrid margin (Part I)Page title, unboxed text, section headings, card and panel borders, table edges, hanging ghost-button labels, tab labels.
Inner rail · 1Container inset, one valueEverything inside a first-level box: titles, field labels, metric labels, a nested table's first cell, buttons inside the card.
Inner rail · 2Indent step, one valueSecond-level content only: an indented sub-list, a tree's child rows, a quoted block. Rare; question it when it appears.
Label columnA fixed track widthValues in inline label–value lists (section VII). It's a rail too, and it should be the same width everywhere the pattern appears.

The Count

This gives a team a test that doesn't depend on anyone's eye. Take a screenshot, draw a vertical line at every x position where text or a visible box begins, and count the distinct positions. Two to four is normal. More than about four is the diagnosis: somewhere a component has brought its own inset to a level that already had one. Lines that land within a few pixels of each other are the near-misses from section I, and they are always the first fix, because they are the ones the eye reads as errors. The overlays on this page are drawn exactly that way, measured from the rendered elements.

The count also explains a common confusion between this part and the spacing chapter. Spacing's §VI lets inset come in shapes (square, squish, stretch) and lets it vary by component. Alignment adds one constraint on top: the horizontal inset of every container at the same nesting level is a single value, because that value is a rail. Cards at 16, panels at 20, and table cells at 12 aren't three inset choices. They are three inner rails. Vertical inset can vary as freely as the spacing chapter allows, because it never creates a rail.

:root { --rail-content: var(--grid-margin); /* 24 or 32, from Part I */ --rail-inner: 16px; /* the one horizontal inset for boxes */ --rail-indent: 16px; /* second level, if it exists */ } .card, .panel, .table-cell:first-child { padding-inline-start: var(--rail-inner); }
Every distinct left edge is a claim that something starts a new level. If no one can name the level, it's a mistake.

IV. Left, Center, Right

Rails are about where content starts. The next question is which way content runs from there. In left-to-right application UI the default is left alignment (more precisely, start alignment, which flips to the right edge in right-to-left languages; logical properties like text-align: start and margin-inline-start handle that for free). Three reasons make left the default, and they are worth knowing because each one predicts where centering fails.

Reading starts at the start edge. Every line of left-aligned text begins in the same place, so the eye's return sweep lands on a known spot. Centered text starts somewhere new on every line. Left alignment leaves a hard edge to align with. A ragged right side costs almost nothing, while a hard left side gives every other element on the screen a rail to share. A centered block has no hard edge on either side, so nothing near it can align to it. Left alignment scales with content. A left-aligned label that grows from 12 characters to 40, through translation or real data, stays anchored. A centered one moves both of its edges, and on a dense screen, everything it was near stops lining up.

No exceptions on this lane Holds, damages, and missed cutoffs will appear here. View history
Empty state · Centered · Right

Short, symmetric, one focus, and nothing else in the region to align with. The group is the whole composition.

Release SHP-20418? Customs has cleared all 146 pieces. Cancel Release
Short confirmation · Centered · Acceptable

One question, one line of body, two buttons. Add a form field or a third line and it should be left-aligned.

Customs hold Held at Montréal on Oct 13 pending a corrected commercial invoice. Dwell charges accrue after 72 hours. Upload invoice
Mixed in one group · Wrong

Centered heading, left body, right button. Three alignments in one card, so it has no edge at all and the heading belongs to nothing.

ContainerSealStatus
NWLU 482117-3A0991Cleared
NWLU 482290-0A1004Held
CRDU 100734-5B2213Cleared
Centered headers, left cells · Wrong

Each header floats over the middle of a column whose values all start at its left. The header no longer labels the edge the eye scans.

Centering is right when the group is the whole composition: symmetric, short, single-focus, and with nothing nearby that it needs to line up with. Empty states, success and confirmation screens, sign-in cards, onboarding steps, and marketing heroes qualify. So do labels inside buttons and icons inside icon buttons, which are centered within their own box. Dialogs fall on both sides. Apple's alerts center their short title and message; most web systems, Material 3 and Carbon among them, left-align dialog content, with Material centering the headline only when a hero icon sits above it. The practical line is length: one question and one sentence can center; anything with a form, a list, or a second paragraph is a small page and gets left alignment.

Centering is wrong whenever it has to coexist with a left edge. A centered heading over left-aligned body text is the most common case; the heading no longer marks where the text below it starts, which is the main thing a heading in a dense screen does. Centered column headers over left-aligned cells are the tabular version. Centered multi-line text in dense UI (a centered description in a card, a centered error under a field) is the third: each line starts in a different place, and the reader has to find the start of each one.

Right alignment has two jobs and only two. Numbers right-align so that place values line up (section VI), and trailing content (actions, totals, timestamps, chevrons) right-aligns to mark the end of a row or a region (section V). Right-aligned prose, or right-aligned labels used to look tidy, is almost never worth what it costs in reading.

ContentAlignWhy
Text, labels, headingsStartA fixed start edge for reading, and a rail for everything nearby.
Numbers that compareEndPlace values stack; magnitude is visible from length alone.
Column headersSame as their cellsA header labels the edge the eye scans down.
Trailing actions, statusEndMarks the end of the row or region; one right rail.
Empty, success, short confirmCenterThe group is the composition; nothing to align with.
Short codes, icons in cellsCenter, sparinglyOnly for fixed-width tokens (a flag, a check) where start and center coincide anyway.
Centering is a composition, not an alignment. It works when the group is everything on screen, and it fails as soon as the group has to line up with anything else.

V. The Right Edge

Teams that audit left edges carefully often forget the right one. Ragged-right text is fine; a ragged right edge of blocks is not. Trailing content creates a right rail as surely as headings create a left one, and the right rail has the same rule: one outer right rail and one inner right rail, shared by everything that ends a row. Actions, status badges, totals, timestamps, chevrons, and overflow menus are all trailing content, and the eye compares their right edges down the screen the same way it compares left edges.

Exceptions · 3 open
Customs hold · MontréalBlocking2h ago
2 pieces damaged · TorontoYesterday
Weight variance −254 kgReviewOct 17
Exceptions · 3 open
Customs hold · MontréalBlocking2h ago
2 pieces damaged · TorontoYesterday
Weight variance −254 kgReviewOct 17
Top · Header actions at the page edge, card inset, optional slots collapsing · Bottom · One right rail outside, one inside In the top version the buttons stop 12px from the edge and the card 22px. The row without a chevron pushes its timestamp to a different right edge.

The first failure is the one in section I's screen: the header's actions sit on one right edge and the content below sits on another. It usually happens because the page header and the card are different components with different horizontal padding. The fix is the same as on the left: the header's actions end on the content rail, which is where the card's border ends.

The second failure is inside rows: optional trailing content that collapses. When some rows have a chevron (because they're navigable) and others don't, or some have a status badge and others don't, a flex row that simply omits the missing element shifts everything after it. The timestamps then end on two or three different right edges. Trailing content belongs in fixed slots: reserve the chevron's width on every row and give the badge a column of its own, so that a missing element leaves empty space instead of moving its neighbors. In a table, columns already guarantee this. A list has to do it on purpose.

Button Groups

Primary at the trailing end · 6–8px between related · Destructive apart, at the leading end
Gap wider than the buttons' inset · Two strangers, not a group

A button group sits on the right rail as a unit, so its order and its internal gap are alignment decisions too. Platforms disagree on order: macOS puts the default button at the trailing end, while Windows has traditionally placed the affirmative button first. Most web design systems, including Carbon and Material, follow the trailing-primary convention, and the reason that holds up is the right rail: the primary action is the last thing in the row, so it sits on the rail where the eye finishes. Pick one order for the whole product. A product that puts Save first in one dialog and last in another trains users to read every button.

The gap inside the group is the spacing chapter's inline-related step (8px, or 6 in compact), smaller than the buttons' own horizontal inset, so the group reads as one object. A destructive action that shouldn't be clicked by habit gets separated from the group — moved to the leading end of the same row — rather than given a different color and left in the middle.

The same separation applies to any irreversible action, destructive or not: release, publish, send, submit for review. These never share a group with a routine action. A routine button is pressed by reflex, and a reflex aimed at Save that lands 8px to the right on Publish ships the thing to everyone, early, with no way back. Put the irreversible action in its own position, never make it the default button, and give it a confirmation step that names what is about to happen. The shipment header in section I does this: Release is the primary, but it stands apart from Hold and Edit and opens a confirmation before anything leaves the yard.

VI. Numbers & Tabular Data

Text is read; numbers are compared. A user looking down a column of costs is not reading each one. They are looking for the longest, the shortest, and the one that stands out, and in a well-set column they can do that before reading a single digit, because magnitude shows up as length. That only works if the digits line up by place value, which takes three things: tabular figures, right alignment, and consistent precision.

LaneShipmentsAvg dwellCostvs Sep
RTM → CHI4231.4 h$1,284,310+4.2%
HAM → NYC1189.75 h902,118.50 USD-11%
ANR → MTL7112 h$48.9k(3.1%)
FXT → TOR1,2064.2 h$11,720.750.4%
Left-aligned · Proportional figures · Mixed precision, units in cells, three ways to write a sign
LaneShipmentsAvg dwell hCost USDvs Sep
RTM → CHI4231.41,284,310+4.2%
HAM → NYC1189.8902,119−11.0%
ANR → MTL7112.048,900−3.1%
FXT → TOR1,2064.211,721+0.4%
Right-aligned · Tabular figures · One precision per column · Units in the header · One minus sign In the second table the largest cost is visibly the longest, and the negative deltas are findable without reading. In the first, the eye has to parse every cell.

Tabular Figures

Most text faces default to proportional figures: a 1 is narrower than a 0, which looks better in a sentence and makes columns wobble. Tabular figures give every digit the same advance width, so a column of numbers forms clean vertical lines. In CSS that's font-variant-numeric: tabular-nums, and it belongs on every table cell, every stat value, every timer, and every number that changes in place. A ticking counter in proportional figures jitters sideways as its digits change.

There's a catch the specimen above runs into. The property switches on the font's tnum feature, and does nothing at all if the font doesn't have one. This page's specimen face, DM Sans as served by Google Fonts, measured identical widths for "1111111" with and without tabular-nums when this was written, so the right-hand table falls back to IBM Plex Mono for its figures. Check your own face the same way before relying on the property: render a run of ones and a run of zeros with it on, and compare the widths. If they differ, the property is silently doing nothing.

.table td, .stat-value, .timer { font-variant-numeric: tabular-nums; /* no effect unless the font ships tnum */ } .table .num, .table th.num { text-align: end; /* the header aligns like its cells */ }

Right Alignment, Precision, and Signs

Right-align every column of numbers that will be compared, and right-align its header with it, so the header labels the edge the eye scans down. Identifiers that happen to be numeric (order numbers, ZIP codes, years in a "Model year" column) are labels, not quantities, and stay left-aligned.

Fix the precision per column. With the same number of decimals in every cell, right alignment is decimal alignment, which is why the second table shows 9.8 and 112.0 rather than 9.75 and 112. True alignment on the decimal point, for columns that must mix precisions, has been proposed in CSS as a string value for text-align but isn't implemented in browsers; the practical substitute is consistent precision, or padding the shorter values to the column's decimal count.

Units and currency go in the header when they're the same for every row ("Cost USD", "Weight kg"). Repeating them in every cell adds width and noise, and when the unit sits in the cell, a right-aligned column ends in a word instead of a digit. When currency really does vary by row, give it its own short column rather than mixing symbols and codes in one.

Pick one way to write a negative number. Either a true minus sign (U+2212, which matches the plus sign's width in most faces, unlike the hyphen) or accounting parentheses, but not both in one product. For deltas, show the sign on positives too (+4.2%), so the sign column lines up and a positive change doesn't read as an unsigned value. Color can reinforce the direction but can't carry it alone.

RuleFailure it prevents
tabular-numsColumns that wobble; counters that jitter as they tick.
End-align quantitiesMagnitudes that can't be compared without reading each value.
Header aligns with cellsA label floating over the wrong edge of its column.
One precision per columnDecimal points that wander; 9.75 looking larger than 112.
Units in the headerColumns that end in letters; doubled width for no information.
One negative style; signed deltas−3.1%, -3.1% and (3.1%) in the same report; positives that look unsigned.
A column of numbers should be readable as a picture before it's read as text. If you have to read every cell to find the biggest one, the column isn't aligned.

VII. Label–Value Pairs & Stat Tiles

Detail screens are mostly pairs: a label and its value, repeated. They come in two layouts, and each has an alignment rule that keeps a set of pairs reading as one thing rather than as a scatter of facts.

CarrierNordwave Lines
VesselMV Haldis
Port of loadingRotterdam
BookingNW-0081-4412
Stacked · Label above value

Scales to long values and narrow columns, and sits on the grid's tracks. The default for summary panels.

CarrierNordwave Lines VesselMV Haldis LoadingMaasvlakte II, berth 7, Rotterdam BookingNW-0081-4412
Inline · Label column · Right

Labels in a fixed track, values on one rail, label on the first line's baseline when a value wraps. Dense inspectors.

Carrier: Nordwave Lines Vessel: MV Haldis Loading: Maasvlakte II, berth 7 Booking: NW-0081-4412
Inline · Ragged · Wrong

Each value starts wherever its label ends. Four values, four edges; scanning the values means reading the labels.

Stacked pairs, label above value, are the default for summary panels and record headers. They handle long values gracefully, they work in narrow columns, and a row of them can sit directly on the grid's column tracks. Inline pairs, label beside value, are denser and suit inspectors and property lists, but only with a label column: a fixed-width track for labels so that every value starts on the same rail. The label column is a rail in the section III sense, and its width should be a token, the same everywhere the pattern appears. Labels in an inline list align with the first line of their value (by baseline, section VIII) so that a value that wraps to three lines doesn't leave its label floating in the middle. And labels are styled one way everywhere: one size, one color, one case. When some labels are uppercase mono and others are sentence-case sans, the eye stops treating them as the same kind of thing.

Stat Tiles

A stat tile (a KPI, a metric, a summary number) is a stacked pair with a promoted value, and rows of them are where dense screens most often look unbalanced even when every tile is fine on its own. Two rules prevent that.

Every tile in a row has the same anatomy: label, value, and delta or context, in the same order, at the same sizes, in the same positions. If one tile has no delta, it keeps the empty slot, so its value still sits on the same line as its neighbors. A row in which one value is larger, one label sits below its number, and one tile has an extra line reads as four unrelated objects that happen to be next to each other.

Stat rows share their column tracks with the grid around them. A row of four tiles above a panel that contains its own row of four metrics is the classic case. If the nested row divides its panel's width privately (with flex, its own padding, its own dividers), its columns end up offset from the tiles above, and its dividers land in the middle of the columns overhead. The fix is to put the nested row on the same tracks, which is exactly what subgrid is for.

Shipments1,373+6.1% vs Sep
On time91.4%−1.2 pts
+0.4 daysAvg transit18.2d
Exceptions27
Throughput by terminal
Rotterdam612
Hamburg388
Antwerp241
Felixstowe132
Wrong · Tiles on the grid, nested metrics on private widths · Mixed tile anatomy
Shipments1,373+6.1% vs Sep
On time91.4%−1.2 pts
Avg transit18.2d+0.4 days
Exceptions27 
Throughput by terminal
Rotterdam612
Hamburg388
Antwerp241
Felixstowe132
Right · Nested row on subgrid · Dividers in the gutters · One anatomy, empty delta slot kept The overlay is the 12-column grid. In the top frame the panel's dividers cut through the middle of the columns above; in the bottom one they sit in the gutters.
.summary-panel { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; /* the page's 12 tracks, not new ones */ } .summary-panel > .metric { grid-column: span 3; padding-inline: var(--rail-inner); } .metric + .metric::before { /* divider centered in the gutter */ inset-inline-start: calc(var(--gutter) / -2); }

The readouts under the two frames make the difference countable: the private row adds a set of label edges that miss the tiles' edges by a few pixels each, while the subgrid row puts every label on the same line as the tile above it. This is Part I's one grid per container rule reaching inside a box. A panel is a container, but when its contents are a row of the same kind of thing as the row above it, they should be on the same grid.

A row of tiles is one object with four values in it. Give every tile the same anatomy and put every row on the same tracks, or the eye will read four objects that don't belong together.

VIII. Vertical Alignment & the Baseline

Everything so far has been about the horizontal axis: where things start and end across the screen. Items in a row also have to agree vertically, and there are three choices: align their tops, their centers, or their baselines, the invisible line letters sit on. Flexbox's align-items offers all three, and most codebases use center for everything. The rule has four lines: within one voice, text aligns by baseline; between two voices, the row's visible edges go on the dominant text's baseline; boxes of equal height align by center; anything that can wrap aligns to the top. A voice is a type size doing one job: a heading is one, the metadata beside it is another. Most rows have one voice, and for them the default is baseline. The row that mixes a heading with small text is the hard case, and it is hard because the eye is aligning lines it can see, which are not always the lines the CSS is aligning.

Small text floats 5px above the baselineExceptions3 openUpdated 4 min agoView all
align-items: center · Wrong · Four line boxes centered, four different baselines
One baseline · The small voice sinks, the pill hangs 4px belowExceptions3 openUpdated 4 min agoView all
align-items: baseline · Wrong at this size ratio · One line for two voices
Visible edges on the baseline · Small text on one lineExceptions3 openUpdated 4 min agoView all
Pill outline and underline on the heading's baseline · Small text shares one baseline · Right Dashed lines are baselines. In the first frame the tinted line boxes are centered, so the small items disagree with each other by a pixel or two and with the heading by five. In the second everything shares the heading's baseline, and the small voice reads as dropped to the floor. In the third the two things the eye can actually see, the pill's outline and the link's underline, sit on the heading's baseline, and the small text shares one baseline above them. Turn the markers off and compare the first and third frames: they differ by a pixel of agreement among the small items.

Within a voice, baseline. A pill, a timestamp, and a link at 10 to 12px are one voice, and align-items: center gives each its own baseline because their line boxes differ in height. The disagreement is only a pixel or two, but it is the pixel or two the eye reads as sloppy. Put them on one baseline and the pill's text, the timestamp, and the link read as a single run, as they would in a sentence. This is the common case, and it is why baseline should be a system's default.

Between voices, put the visible edges on the baseline. Extending the small voice's baseline to the 28px heading is the second failure: the small text sits in the bottom quarter of the heading's letters and reads as fallen, and the pill hangs its outline below the line. The reason is that a baseline is invisible, and the eye aligns what it can see. The heading's baseline is visible, as the bottoms of its letters. The pill's outline is visible. The link's underline is visible. Those three lines want to be one line, and once they are, the small text lands where its boxes put it, about six pixels up, which is close to the middle of the heading's capitals and reads as deliberate. The first frame looks nearly right for exactly this reason: centering happened to drop the pill's bottom and the underline onto the heading's baseline, and its only flaw is that the small texts disagree with each other by a pixel. In CSS the fix is a nested flex: the small items in their own row aligned by baseline, that row placed on the heading's baseline, then raised by the pill's descent below its text, so the pill's outline rather than its text sits on the line. Where nothing in the small voice has a visible edge, center it on the capitals, which lands within a pixel of the same place. Where the size ratio is larger still, or the small voice is long, use a second line under the heading.

Boxes of equal height align by center. An input and a button built on the same height token are two boxes, and centering them is the same as aligning their tops; this is the one case where center is correct, and it is correct only because the heights match. The moment a control sits beside text of another size, such as a small button at the end of a large heading, it is a text case again: use baseline, and the button's label lands on the heading's baseline. Matching control heights is its own topic, covered in Text Inputs.

Icons Beside Text

HeldBaseline · Sits high
Heldmiddle · Centers on x-height · Low
HeldCap-height center · Right
Dashed lines are the cap height and the baseline. The third icon is centered between them with vertical-align: calc(0.5cap − 0.4em).

Icons align to text by the center of the capital letters, not by the line box and not by the lowercase letters. The eye judges an icon against the height of the label's capitals, so an icon centered on the space between baseline and cap height looks centered. The CSS keyword that sounds right, vertical-align: middle, actually centers on the baseline plus half the x-height, the middle of the lowercase letters, which puts icons visibly low. In a flex row, align-items: center centers the icon on the text's line box, which coincides with the cap-height center only when the font's ascent and descent happen to balance; it is close for some faces and off by a pixel or two for others. Apple's SF Symbols are designed to align with the text they accompany, which is why icons in Apple's interfaces rarely look low. With other icon sets, the cap unit (supported in current browsers) lets you compute the offset instead of nudging by eye.

Multi-Line Rows and Column Tops

Release hold once customs confirms the corrected commercial invoice2h
Center · Checkbox floats mid-paragraph
Release hold once customs confirms the corrected commercial invoice2h
Start · Aligned to the first line

When any item in a row can wrap, align to the top and center the leading element on the first line (here, a 2px offset: the 18px line minus the 14px box, halved). A checkbox, avatar, or icon centered beside a three-line comment drifts down to the middle of the paragraph and stops marking where the item starts. The same applies at the scale of columns: in a multi-column layout, adjacent cards and columns align their tops, so their headings sit on one line. Vertically centering a short card beside a tall one leaves both headings stranded at different heights.

PairAlign byCSS
Text ↔ text, one voiceBaselinealign-items: baseline (or last baseline for a footer row)
Small voice ↔ large headingSmall items on one baseline; their visible edges (pill outline, underline) on the heading's baselineNested flex: inner baseline, outer baseline, cluster raised by the pill's descent; or a second line
Box ↔ box, equal heightsCenter or top; identicalalign-items: center
Pill or control ↔ larger textIts bottom edge on the text's baselinealign-self: baseline raised by its own descent, or flex-end + the heading's descent
Icon ↔ textCap-height centerFixed line-height and flex center, or vertical-align: calc(0.5cap − h/2)
Anything ↔ wrapping textTop; leading item on the first linealign-items: flex-start + offset
Column ↔ columnTopalign-items: start on the grid
The eye aligns the lines it can see. Within a voice, baseline. Between voices, every visible edge in the row sits on the dominant text's baseline, and the small text follows its boxes. Box to box by edge, icon to text by the middle of the capitals.

IX. Optical Alignment

Everything up to here has been measurable: draw the line, check the edge. The last category is where measuring gives the wrong answer. CSS aligns bounding boxes; the eye judges shapes by their mass and their contours. Where a shape doesn't fill its box (a circle, a triangle, a round letter, a quotation mark), mathematically correct alignment looks wrong, and the fix is to adjust the geometry so the shape looks right.

36 / 36 · then 36 / 40

A circle the same size as a square looks smaller, because it has less area. Round shapes overshoot their box to look equal.

Box centered · then centroid centered

A play triangle centered by its box looks shifted left, because its mass is near the flat side. Shifting it right by about a sixth of its width centers its centroid.

OverviewStops, documents, events
OverviewStops, documents, events
Side bearing · then pulled back

At display sizes the O's built-in side bearing becomes a visible indent. Pulling the heading back about 0.05em puts the curve on the rail.

“Release only after customs clears the invoice.”Ops note, Oct 13
“Release only after customs clears the invoice.”Ops note, Oct 13
Quote inside · then hanging

With the opening quote inside the edge, the text looks indented. Hanging the mark outside keeps the letters on the rail.

The four cases have one thing in common: the shape doesn't fill its box, so the box is the wrong thing to align. Type designers handle this inside the font. Round letters like O and C extend slightly above the cap height and below the baseline (called overshoot) so they look the same height as H. Icon systems handle it in their grids: Material's system icon guidance, for example, gives circles a larger keyline than squares within the same 24dp icon for the same reason. Interfaces have to handle the rest. The play icon is the classic case. The triangle's centroid sits a third of the way in from its flat side, so a box-centered triangle has its visual mass left of center. Moving it right by a sixth of its width centers the centroid exactly; many designers stop a little short of that, and either is better than zero.

Display type is the second case. Every letter has a small built-in margin, its side bearing, which is invisible at 14px and becomes a visible indent at 42px, especially on round letters. A large page title above body text often needs a negative offset of a few hundredths of an em to look aligned. The third is punctuation: an opening quotation mark, a bullet, or a leading dash belongs outside the text's edge, so the letters keep the rail. CSS has a property for this, hanging-punctuation, but at the time of writing only Safari supports it, so a negative margin on the mark is the portable version.

When to Cheat, and How to Keep the Cheat

Optical corrections are worth making where the shape is large or repeated: display headings, primary icon buttons, media controls, avatars beside square thumbnails, the bullet style of the whole product. They aren't worth making case by case in individual screens, where they become magic numbers nobody can explain. The rule that keeps them sustainable has two parts. Put the correction in the component, once, so every instance gets it. And document it in place, because an optical correction looks exactly like a bug to the next person who reads the code, and the most common fate of a good optical fix is being "fixed" back to mathematical alignment during a refactor.

/* OPTICAL: the play glyph is shifted right so its centroid, not its bounding box, sits at the button's center. ~1/6 of glyph width. Intentional — see Grid & Layout II §IX before changing. */ .icon-play { translate: 0.1em 0; } /* OPTICAL: display headings pull back to cancel the side bearing. */ .page-title { margin-inline-start: -0.05em; }
Optical corrections belong to the system, not to the screen: decided once, built into the component, and commented so no one fixes them back.

X. Dividers, Rules & Nested Boxes

A divider is the only alignment element that's literally a line. Everywhere else, the eye has to infer the rail from edges; a divider draws it. That makes dividers the place where misalignment is most visible, and it makes the rule for vertical dividers simple: a divider between columns sits on the grid, in the middle of a gutter, never at an arbitrary percentage of its container.

Divider at 38% · Wrong

The card's internal split was set by its content. The rule lands under the middle of the first box above, a line that agrees with nothing.

Divider in the gutter · Right

The card subgrids the page's tracks; the rule runs down the same gutter that separates the two boxes above it.

Nested Boxes Take One Inner Rail

The other place rails multiply is nesting. A panel inside a card inside a region, each with its own border and its own inset, adds a rail per level: 16, then 32, then 48. Each box looks reasonable alone; together they push the innermost content a long way from everything else, and each level is one more edge to align. The spacing chapter's nesting rule governs the vertical gaps between those levels; the alignment rule is about their horizontal edges, and it is stricter: a nested group inside a box shares the box's inner rail. If it needs to look distinct, it gets a band (a full-width tint or a pair of rules that bleed to the box's edges) rather than a new box with a new inset.

CustomsEntry filed Oct 12
Hold · MontréalInvoice value mismatch
Declared $214,900Invoiced $221,400
Box in box in box · Wrong

Each level adds its own inset, so three levels of content give three rails, and the innermost text has moved far from the heading it belongs to.

CustomsEntry filed Oct 12
Hold · MontréalInvoice value mismatch
Declared $214,900Invoiced $221,400
Bands on one rail · Right

The nested groups are bands that bleed to the panel's edges. Their content stays on the panel's inner rail.

Documents3 of 4 received
Commercial invoicev2
Bill of ladingv1
Packing listv1
Full-bleed rules · Sections

A rule that runs edge to edge divides the box into parts: header, body, footer. Each row reads as its own section.

Documents3 of 4 received
Commercial invoicev2
Bill of ladingv1
Packing listv1
Inset rules · Items

Rules that start on the inner rail separate items within one list. The list reads as one group hanging off its heading.

Horizontal rules make a quieter claim of their own. A full-bleed rule, edge to edge of its container, divides the container into sections: it says the things above and below are different parts. An inset rule, starting on the inner rail, separates items within one group: it says the rows are siblings, and the rail they start from is the list's edge. Apple's grouped lists use the inset form for exactly that reason. Both are correct; using both in one card for the same relationship is not. Pick by the relationship. Stacked panels on one page follow the same logic as stacked cards: every panel at the same level has the same inset, so their inner rails line up down the page even when their borders differ.

A divider is a drawn rail. Put it where a rail already is, in a gutter or on an inset, or it becomes the most visible misalignment on the screen.

XI. Auditing a Screen

Everything above reduces to a check a team can run on any screen, by anyone, in about fifteen minutes, without a debate about taste. Here is the screen from section I after one pass of it.

Shipments / Ocean + railSHP-20418Rotterdam → Chicago · booked Sep 26
CarrierNordwave Lines
ModeOcean → rail
ETAOct 29
IncotermsCIF Chicago
Pieces1462 damaged
Gross weight18,166kg−254 vs booked
Volume62.4m³of 67.7 booked
Declared value$214,900USD · CIF
OverviewStopsDocumentsEvents
FacilityArrivedDwell hPiecesWeight kg
Rotterdam · Maasvlakte IISep 3018.514818,420
Montréal · Berth 62Oct 13112.014818,420
Toronto · Rail yard 4Oct 176.314618,166
Chicago · CorwithOct 29 est.———
Measuring… After the audit · Same components, same content · Insets reassigned to two rails Compare the readout with section I's. Nothing was redesigned; every change is a padding, a margin, or an alignment value.
CheckFound in §IFix
Left railsSix positions: 24, 32, 36, 40, 53, 66Two: content rail 24, inner rail 41. Card moved out to the rail; table given the card's box and inset.
Right railsButtons, card, and nested panel on three edgesActions, card, tabs, and table end on one outer rail; last numeric column ends on the inner one.
TabsLabels 16px in from the railTab list pulled back by the tab's own inset; labels hang on the rail, indicator under the label (§II).
Nested panelA second box with a second insetA full-bleed band; its content on the card's inner rail (§X).
Tiles and fieldsPrivate widths; one label below its value; one missing deltaFields and metrics on the same four tracks; one anatomy; every slot filled (§VII).
NumbersLeft-aligned, proportional, mixed precision; headers centeredEnd-aligned tabular figures, one decimal, headers aligned with their cells (§VI).
VerticalActions aligned to the breadcrumbActions aligned to the title line (§VIII).

The Method

Screenshot at a real width. Use the width people actually use (1440 for most desktop products), with real data, including the longest name and the empty state. Alignment problems hide in placeholder content.

Draw the left rails and count them. One vertical line at every x position where text or a visible box begins. Two to four is healthy; more is the diagnosis. Mark any two lines within about 12px of each other: those are the near-misses, and they are the ones users feel.

Draw the right rails. Same exercise for trailing edges: actions, card borders, badges, timestamps, the ends of numeric columns. Look especially at the page header against the content below it.

Check the numbers, the tiles, and the dividers. Every numeric column end-aligned, tabular, one precision, header aligned with cells. Every tile in a row with the same anatomy, every stat row on the tracks of the grid around it. Every vertical divider in a gutter, every horizontal rule either full-bleed or on the inner rail for a reason.

Check baselines and icons last. Rows with mixed text sizes, icons beside labels, wrapped rows with leading checkboxes or avatars.

Fix in the same order, because each step makes the next one easier to see. Rails first, because they are tokens (the content rail, the inner inset) and fixing one value usually removes several lines at once. Then edges: which components hang and which sit, which tables get a box. Then baselines, which are local to rows. Then optics, which only matter once everything around them is right. A team that does this on its three busiest screens usually finds the same pattern the spacing audit finds: not forty problems, but four or five component insets that disagree, each repeated everywhere the component appears.

On a Phone

Mobile is a reducing layer here as everywhere else. At 375px there is one column, so the rail budget shrinks to two: the page margin and one inner rail. Second-level indents usually go away (a tree becomes drill-in navigation), label columns become stacked pairs, and right rails collapse to the same two. The fixed screen above reduces cleanly because it already uses only two. What has to survive is the shared edge: every heading, card, tab label, and list row on the one margin, every piece of boxed content on the one inner rail. With less width there are fewer things to compare, so each near-miss is easier to see.

Count the edges before you argue about taste. Most "it just looks off" conversations end the moment someone draws the lines.

XII. The Decision Sequence

Alignment decisions depend on each other the same way Part I's layout decisions do, and most alignment drift comes from deciding them per component rather than per system. In order, written down once for a product:

1
Name the railsContent rail = grid margin. One inner rail per visible nesting level, usually one, rarely two. A label-column width if inline pairs exist.
2
Give every container at a level one horizontal insetCards, panels, table cells, and dialog bodies at the same level use the same inline inset. Vertical inset stays free.
3
Decide what hangsVisible at rest sits on the rail; visible only on interaction hangs. Ghost buttons, tabs, list rows, icon buttons: encoded in the component.
4
Set alignment defaults by contentText start, quantities end, headers with their cells, center only for whole-composition groups.
5
Fix the number rulesA face with real tabular figures, precision per column, units in headers, one negative style.
6
Define pair and tile anatomyOne label style, one stacked and one inline pattern, one tile anatomy, rows on the surrounding grid's tracks.
7
Encode the vertical rules and the opticsBaseline for text rows, cap-height for icons, top for wrapping rows. Optical corrections in components, commented.
8
AuditDraw and count rails on the busiest screens each release. The check catches what the first seven steps missed.

Steps one through seven are system decisions that change rarely and live in tokens and components. Step eight is the review habit, and it is the step that turns "it looks off" into a list of edges that can be fixed.

What the Best Systems Avoid

Insets chosen per component. A card at 16, a panel at 20, a table cell at 12, a tab at 16. Each is defensible alone, and together they are the single largest source of extra rails. Horizontal inset at a nesting level is one value.

Ghost controls with their boxes on the line. Text buttons, tabs, and hoverable rows whose invisible boxes are aligned while their visible labels sit 8 to 12px in. It's the most common near-miss in otherwise careful products.

Center as a default. Centered headings over left-aligned content, centered column headers, centered descriptions in cards. Centering is for the few compositions that stand alone.

Proportional, left-aligned numbers. Tables and stat tiles whose figures can't be compared without reading them, often in a face whose tabular-nums does nothing because no one checked.

Private tracks inside panels. Metric rows, field rows, and split cards that divide their own width when they sit under a grid they could have shared, with dividers landing mid-column as a result.

Uncommented optical fixes. Corrections nudged by eye in a screen file, which the next refactor quietly removes.

This part has been about edges and axes within one screen. Part III takes up composition: how collections size their columns, how card grids handle uneven content, how a list becomes master/detail, and how a dense detail screen is put together from summary, tabs, and collection so that its rails hold from the header to the last row.

Part II of Grid & Layout. Continues The Frame & The Column Grid.
Nobody notices an edge that lines up. Everybody feels the one that almost does.