Sub topic 7
Grids, Spacing, and Alignment
Assume you understand basic HTML and CSS, common interface elements, and the purpose of a wireframe. This chapter focuses on turning a rough screen idea into a layout that is consistent, readable, and adaptable.
Build a grid before placing components
A layout grid is an invisible structure that organizes content. It usually contains columns, gutters, and outer margins.
- Columns define the available vertical tracks.
- Gutters are the spaces between columns.
- Outer margins separate the content from the screen edge.
- Rows or spacing rules help align elements vertically.
A 12-column grid works well for wide web screens because many widths divide evenly. A four-column grid is often easier to use on a narrow phone screen. The exact number matters less than applying the same rule across related screens.
<style>
.screen {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 16px;
padding: 16px;
}
.main, .sidebar {
grid-column: 1 / -1;
}
@media (min-width: 768px) {
.screen {
grid-template-columns: repeat(8, 1fr);
}
}
@media (min-width: 1024px) {
.screen {
grid-template-columns: repeat(12, 1fr);
gap: 24px;
padding: 24px;
}
.main {
grid-column: span 8;
}
.sidebar {
grid-column: span 4;
}
}
</style>
<main class="screen">
<section class="main">
<h1>Order history</h1>
<p>Review recent purchases and delivery status.</p>
</section>
<aside class="sidebar">
<h2>Filters</h2>
</aside>
</main>Use spacing as a system
Spacing communicates relationships. A small gap can show that a label belongs to an input. A larger gap can separate one section from another.
Choose a small set of spacing values instead of inventing a new value for every element. For example:
| Token | Value | Typical use |
|---|---|---|
| small | 8 px | Label and input |
| medium | 16 px | Form fields and cards |
| large | 24 px | Sections |
| extra-large | 40 px | Major page regions |
Consistency makes a wireframe easier to scan and gives developers clear implementation rules. Record unusual spacing in an annotation rather than leaving it ambiguous.
Align for hierarchy and scanning
Align headings, body text, controls, and cards along shared edges. Left alignment usually supports fast reading in left-to-right languages. Center alignment can work for short, focused messages, such as an empty state.
Use alignment to show priority:
- Place the page title near the top.
- Put the main task or content in the strongest visual position.
- Group related controls close to that content.
- Keep secondary actions visually and spatially quieter.
Check layouts at each breakpoint
Do not simply shrink a desktop wireframe. Decide what changes when space becomes limited. A sidebar may move below the main content, navigation may collapse into a menu, and labels may become shorter. Annotate these changes so the responsive behavior is testable.
Exercise
A desktop wireframe places filters in a four-column sidebar beside eight columns of results. What should you decide for a narrow phone layout?
Show answer
Decide whether the filters move below the results, open in a separate panel, or appear behind a filter button. Record the chosen behavior and spacing rule as an annotation.