Practical web UI/UX / personal lessonsLesson 3 of 15
Practical web UI/UX · Lesson 3

Refactor spacing around relationships

Useful spacing distinguishes groups and makes alignment predictable. Uniform padding everywhere does not express every relationship.

By the end: adjust internal and between-group spacing while keeping text and controls readable.

Group before enclosing

Treat a title and its supporting description as one unit. Treat a label and its value as another. Give related elements less separation than unrelated groups. A border is useful when it marks a real boundary; wrapping every line in a box can make a simple card harder to scan.

Alignment gives repeated information a shared starting point. Keep labels and values in a predictable arrangement. Do not distribute gaps merely to fill a fixed height: that can detach a short label from its field or create inconsistent relationships between otherwise similar cards.

Decide which facts belong together

Imagine checking whether Clay basics fits your Saturday. You need its identity, its time and place, and the possibility of reserving a place. Those facts answer related but different questions. Spacing gives you evidence about which lines to read together before you operate anything. A date far from its time asks you to reconnect them mentally. A status touching the next card's title can appear to describe that other workshop. Neither problem requires missing information; the relationships themselves are unclear.

Begin with the words rather than an empty rectangle. In this card, the workshop name and short description form an identity group. When, Where, and Available form a facts group. The reservation and details actions, optional details text, and reservation status form an action group. This grouping does not mean every fact has equal importance. Availability still matters to the reservation decision. It means the reader can find a small, coherent set of facts without interpreting every individual line as a separate panel.

Consider a constructed alternative in which When sits halfway between Saturday, 14:00 and West studio. Both values are present, but the spacing weakens the label's ownership of its value. Move the label closer to the time while keeping a larger separation before Where. The intermediate improvement is a recognizable label/value pair. Repeat that relationship for location. Only then judge the distance between the resulting pairs. Adding a border around the entire card would not repair the ambiguity inside it.

Which value belongs to When?

Static example: ambiguous ownership
Saturday, 14:00
When
West studio
Where
Static example: explicit pairs
When
Saturday, 14:00
Where
West studio
The left example gives the label similar separation from two values. The right keeps each label with its value, then separates the pairs. The words and facts are unchanged; this is a static relationship example, not the lab's adjustable gap.

Alignment supplies a second clue. If When and Where start at the same horizontal position, someone returning to check the location has a predictable place to look. A centered arrangement gives different length lines different starting points. That is not inherently wrong, but it makes comparing repeated facts a different reading task. For this application card, a shared left edge supports repeated lookup. On a short invitation with one title and one date, centered text may impose much less comparison work.

The static examples below keep the session facts unchanged so the relationship change is visible. Read only the labels first, then attach each value to its label. Notice whether the spaces suggest the same pairs as the words. This is an inspection of a specific possible confusion, not a test proving how quickly everyone will read. If you already know the content, you can reconstruct a poor arrangement from memory. A first visitor does not have that advantage when choosing a session.

A useful boundary must answer a question. The outside of a workshop card can separate Clay basics from Ink printing. An extra rectangle around Saturday, another around West studio, and another around availability can imply independent objects even though they describe one session. Removing those rectangles is sensible only if spacing and alignment still explain the relationships. Do not remove the visible edge of an editable field merely because ordinary metadata needs fewer boxes. Controls and descriptive facts have different identification requirements.

Three groups inside one workshop

Static annotated card; action names are text only
Identity group
Weekend workshop
Clay basics
Make a small piece with a tutor.
Facts group
When
Saturday, 14:00
Where
West studio
Available
3 places in this demo
Action group
Reservation action wording
Reserve a place
Details action wording
View details
Current status
No local reservation made.
These annotated groups describe one session. Identity establishes the object, facts support the decision, and the action group includes evidence about the result. The annotation borders are explanatory, not a proposal to put nested boxes around every line.

Try the interface

Your task: Try compact, grouped, and spacious presets. Change the selected group gap and compare the date/location pair with the action group.

Refactor the working workshop card

Studio Desk demonstration. Actions affect this page only, not a real booking, account, or payment.

Reference card treatment

Weekend workshop

Clay basics

Make a small piece with a tutor.

When
Saturday, 14:00

Where
West studio

Available
3 places in this demo

No local reservation made.

Selected card treatment

Weekend workshop

Clay basics

Make a small piece with a tutor.

When
Saturday, 14:00

Where
West studio

Available
3 places in this demo

No local reservation made.

Only the selected treatment changes. The reference holds this lesson's starting treatment; unrelated style settings match across both sides. Design controls preserve local card feedback; Reset comparison restores both cards and the design controls. These alternatives are not assigned a quality score.

Read what the gap control actually changes

Start the working comparison with Balanced groups selected. The reference card keeps an eight CSS pixel gap between its three groups. The selected card starts at sixteen. A CSS pixel is a browser layout unit, not a promise of one physical display pixel. In both cards, the title remains twenty four CSS pixels, the internal paragraph treatment remains the same, and the buttons retain their dimensions. You are changing separation between groups, not shrinking their contents or changing the reservation rule.

Select Compact groups, then Spacious groups, while locating the end of the description and the start of When. Those are different groups, so their separation changes. Now inspect When and Saturday, 14:00. They remain inside one paragraph with a line break, so that relationship does not acquire the selected group gap. This distinction explains why a spacing control can make the card taller without spreading every line apart. The card uses a vertical flexible layout with a gap between contained groups.

There are three groups and therefore two intervening group gaps. Changing the selected value from eight to twenty four adds sixteen CSS pixels at each boundary, or thirty two across both boundaries. That arithmetic isolates the gap contribution if the content, wrapping, and other styles remain unchanged. It is not the total card height. Padding, borders, paragraph margins, line height, and the action stack also occupy space. The schematic shows the counted boundaries rather than pretending its enlarged blocks are measured browser rectangles.

Count the two boundaries, not every line

8 CSS px per gap24 CSS px per gapIdentityFactsActions8 CSS px gap8 CSS px gapGap total: 16 CSS pxIdentityFactsActions24 CSS px gap24 CSS px gapGap total: 48 CSS px
The live card has three groups and two flex gaps. Moving from 8 to 24 CSS px adds 16 at each boundary, so the gap contribution grows by 32 CSS px with other content held fixed. This enlarged schematic is not a pixel-scale rendering of the card or a prediction of its total height.

Reserve a place on the selected card at sixteen, then change to twenty four. The action label remains Release demo place, availability remains two, and the reservation status remains visible. Styling presets preserve that card's local state. The reference remains independently unreserved with three available places unless you operate its own action. This gives you a useful comparison of geometry without accidentally treating a design preset as a new booking. Release restores the selected card's local count; it does not contact inventory.

Open View details and use the slider at twelve and twenty. Materials included and the apron instruction appear inside the action group. They add content there, rather than introducing a fourth top level group. The slider and named presets set the same selected gap. At twelve or twenty, no named preset matches, which is an honest indication that you chose an intermediate value. Look for whether the availability facts now seem detached from the action they help you decide to take.

Style changes do not release a place

Selected-card stepGapLocal evidence
Start16 CSS px3 available; no local reservation
Reserve a place16 CSS px2 available; Release demo place
Choose Spacious groups24 CSS pxStill 2 available; reservation retained
Reset comparison16 CSS px3 available; details closed; both cards reset
A layout preset changes the selected card's gap while preserving its reservation and details state. Reset remounts both cards and clears their local state. The reference is independent, so reserving the selected card never reduces the reference count.

Finish with Reset comparison and inspect both cards again. It restores the selected gap to sixteen and clears local reservations and opened details on both sides. Reset is deliberately different from a style preset. A repeated comparison is misleading if one side includes extra details and the other does not, unless that difference is the state you intend to investigate. Match the content state before judging spacing alone, then introduce the expanded details on both sides to test whether your preferred separation still works.

Choose density without sacrificing controls

Density is how much useful information fits in a given area. Reducing secondary decoration or redundant words may improve density without reducing type size. Shrinking every control creates a different problem, especially for touch and motor access.

The selected card changes the gap between groups while preserving its internal label/value relationships and control sizes. The reference keeps its original treatment. Presets replace the selected gap; the slider changes that same value. More space is not always better: excessive gaps can separate facts needed for one decision.

Choose useful density for the decision

Suppose an organizer compares several workshops to answer which session still has places. A layout that fits one additional card is helpful only if the relevant counts remain easy to associate with session names. Density therefore depends on the information needed for that task, not simply the number of rectangles visible. In a booking list, hiding session identity to expose more rows can defeat the comparison. In a single workshop's detail view, keeping every administrative field visible can bury the next useful action.

Work through a small reduction without changing the facts. Begin with three repeated sentences that each start with Workshop information before giving time, place, or capacity. Remove that repeated introduction and keep the specific labels When, Where, and Available. The intermediate result uses fewer words while retaining three distinct facts. Next align the labels and values consistently. Only after those changes should you consider reducing between group space. This sequence avoids attributing a content improvement to a smaller gap or using tiny type to compensate for repetition.

Remove repeated words before shrinking the reader's text

Static example: repeated introduction
Workshop information: When
Saturday, 14:00
Workshop information: Where
West studio
Workshop information: Available
3 places in this demo
Static copy revision: specific labels
When
Saturday, 14:00
Where
West studio
Available
3 places in this demo
This is an explicit copy edit, not a live spacing preset. The same time, location, and availability survive. Removing the repeated introduction creates room without changing the facts or reducing text size, but it does not by itself establish improved task performance.

In the actual comparison, the compact setting does not remove any text, so it answers a narrower question. Try finding West studio, then checking availability, then opening details. Compare eight and twenty four with the same expanded state. At eight, the groups may feel like one continuous block. At twenty four, the extra separation may make the action feel less connected to availability. Which matters depends on the task and available room. Neither setting has a built in quality score or a measured attention advantage.

Now imagine a staff view that needs only identity and availability until someone investigates a particular workshop. It could place the fuller description in a discoverable detail view. This is a proposed application change, not a hidden control in this lab. The important question is what people would need to open repeatedly. Moving the location away would be costly if organizers routinely compare rooms. A detail view reduces visible content only by asking people to retrieve that content later when they need it.

Control size is a separate constraint. The working card buttons have a minimum height of forty four CSS pixels and retain their padding while the group gap changes. A gap of eight does not mean an eight pixel target. Smaller targets can create accidental operations even if the card looks tidy. Conversely, a generous target does not make adjacent actions unambiguous. Reserve a place and View details still require distinct wording and useful feedback so someone knows which operation occurred and whether anything consequential happened.

A control's height and a group gap are different dimensions

Facts groupGroup gap8–24 CSS pxAction area schematicButton minimum44 CSS px highNot to scale; these are separate constraints.
The live CSS sets a 44 CSS px minimum button height, while the layout setting changes the separate 8–24 CSS px gap between groups. Padding and wrapped wording can make the real button taller. This schematic enlarges the gap for legibility and cannot establish touch accuracy or perceived grouping.

Use a concrete question when comparing a revision with someone else. Ask them to determine where Clay basics takes place and whether they can reserve a place, without telling them to inspect the facts group. Observe wrong associations, unnecessary detail opening, and uncertainty about the resulting local status. A preference for the spacious version is useful preference evidence, but it does not establish fewer mistakes. If you also rewrite labels and change spacing, any observed improvement belongs to the combined treatment until you compare those changes separately.

Let real content determine height

A fixed-height card may look aligned with short placeholders yet clip a long session name or validation message. Prefer content-driven height unless a real interaction requires a bounded region. A visually even grid is not worth hiding essential text.

For constrained applications, decide which information must remain visible and which can move into a clearly labeled detail view. Do not silently truncate a distinguishing name. If truncation is necessary, provide a reliable way to obtain the complete value.

Allow the card to grow with its state

A card is not one permanent arrangement of words. In the working example, opening details adds the materials and apron message, reserving changes the action label, and the status describes the current local reservation. A layout chosen only for the initial unreserved state has not faced all its content. None of these actions requires a fixed height. Letting the card grow preserves the extra explanation while retaining the same group structure. Equal starting heights are less valuable than keeping the changed state understandable.

Trace the details transition before judging the extra height. Initially, View details offers an available action and the instruction paragraph is absent. After activation, Hide details names the reverse action and the materials paragraph is present. The status underneath still describes reservation state, which is independent of details visibility. If an imagined fixed height clipped the bottom lines, it might hide the reservation evidence rather than the new paragraph. Clipping order is a layout consequence, not a reliable rule for choosing which information matters least.

Extra details grow the action group

Static action-group excerpt: closed
Reservation action wording
Reserve a place
Details action wording
View details
Current status
No local reservation made.
Static action-group excerpt: open
Reservation action wording
Reserve a place
Details action wording
Hide details
Materials included. Bring an apron. This is a fictional session.
Current status
No local reservation made.
Opening details inserts the materials paragraph and changes View details to Hide details. Reservation state remains unchanged. A content-driven card grows downward, keeping the status after the added text rather than sacrificing that status to a fixed height.

For a paper stress case, replace Clay basics with Introduction to hand built ceramics and surface decoration. This is an explicit content change in the static specimen, not a title editor in the spacing lab. The extra words can wrap to additional lines at the same width. Keep the complete identity and let the height increase before considering an appropriate smaller heading treatment. Cropping to Introduction would make many different sessions indistinguishable. The original short title could never reveal that particular failure.

In a real form, an error adds another kind of content. A message belongs close to the affected field, while a larger break can separate the completed field group from the action area. An empty layout with evenly distributed vertical space may look balanced until an error arrives. Then the same fixed allocation can detach a label, overlap another field, or conceal the action. Reserve room only when the expected content warrants it; no single reserved height can guarantee space for every translated or enlarged message.

Longer identity needs room, not an indistinguishable crop

Static short-title example
Weekend workshop
Clay basics
Make a small piece with a tutor.
When
Saturday, 14:00
Where
West studio
Available
3 places in this demo
Static changed-title stress case
Weekend workshop
Introduction to hand built ceramics and surface decoration
Make a small piece with a tutor.
When
Saturday, 14:00
Where
West studio
Available
3 places in this demo
The right specimen explicitly substitutes a longer title; it is not an additional spacing-lab control. Both specimens keep a 24 CSS px title and the same session facts. Their natural heights preserve all words, which is more important than forcing the starting cards into equal-height boxes.

Try browser zoom on this lesson while keeping both working cards visible when the available space permits. Look for wrapping changes, then open details on both cards and read through the statuses. Zoom can reduce the effective layout space as well as enlarge text. If a comparison stops fitting, do not treat successful inspection at one zoom as proof of complete reflow support. The later responsive example tests a different constraint explicitly. Here the evidence is whether the current content remains available without overlap or clipping.

For transfer, take a settings panel you can inspect without changing real account data. Identify its tightest label/value relationships and the boundaries between different decisions. Imagine one longer value and one useful error message. Specify which group grows and which next group moves downward. Then compare that prediction with the panel's actual behavior if a safe demonstration is available. A successful revision preserves identity, state evidence, and operable actions as content grows. It does not merely reproduce equal rectangles from the original empty screenshot.

Exercises

Fix a crowded card without tiny text

An organizer wants more bookings visible at once. Name two changes to try before shrinking all text and controls.

Hint

Look for repetition and irrelevant columns.

Worked answer
ChangeCheck
Remove repeated decorationRelationships still clear
Reduce secondary fieldsDetail remains discoverable
Keep control sizeActions remain operable
Density is a content and layout decision.

Remove redundant labels or decorative containers, and show only the fields needed for the current decision while keeping a discoverable detail view. Keep important identifiers and state visible. Test with long content and actual tasks rather than judging the number of rows alone.

Explain an overflow failure

Cards have equal fixed heights, but one loses its last line when an error appears. What is the first constraint to reconsider?

Hint

The content changed while the allotted height did not.

Worked answer
StateRequired capacity
NormalLabels, inputs, actions
ErrorSame content plus useful feedback
Expanded textMore vertical room
The layout must accommodate its states.

Reconsider the fixed height. Let the card grow or allocate an appropriate error region without clipping, then check neighboring layout and focus visibility. Moving the error into an unlabeled tooltip would not make it reliably available.

Sources and further reading

Selected guidance and technical definitions were reviewed, not a complete usability literature or accessibility audit. The interfaces are original teaching examples. They do not establish measured improvements in task performance. These optional links are not runtime dependencies.