Sub topic 4
Visual hierarchy: guiding the eye with size, contrast and space
This chapter assumes you know basic HTML and CSS and the common page parts: header, navigation, hero section and call to action. It also assumes you have read the earlier chapters on why people scan and what the F-pattern showed. Scanning patterns describe where eyes tend to go. Visual hierarchy is the tool you use to steer them.
What visual hierarchy is
Visual hierarchy is the order in which a viewer notices the elements on a page. Designers set that order on purpose with four levers: size, contrast, whitespace and position. A scanning reader does not weigh every element equally. The eye lands first on whatever stands out most, then moves to the next most prominent thing.
If everything is emphasized, nothing is. A page with five bold colors and four large headings gives the eye no clear starting point, so the reader falls back on a default path, often the F-pattern or simply the top left.
The four levers
| Lever | What it does | Typical CSS |
|---|---|---|
| Size | Larger elements attract the eye first | `font-size`, `width`, `height` |
| Contrast | Elements that differ from their surroundings stand out | `color`, `background`, `font-weight` |
| Whitespace | Empty space isolates an element and groups related ones | `margin`, `padding`, `gap` |
| Position | Top and left (in left-to-right languages) get seen first | Document order, grid and flex layout |
Size
Make the most important element the largest. A page title should be bigger than section headings, and section headings bigger than body text. Keep a clear step between levels. Sizes of 2rem, 1.5rem and 1rem read as three distinct levels. Sizes of 1.1rem, 1.05rem and 1rem look like a mistake.
Contrast
Contrast means a visible difference in color, weight or shape. A single saturated button on a quiet page is seen at once. Contrast also affects readability. Body text needs enough contrast against its background, and the WCAG accessibility guidelines set a minimum ratio of 4.5:1 for normal-size text.
Whitespace
Whitespace is the empty space around and between elements. It does two jobs. It separates unrelated things, and it keeps related things together. Space around a call to action makes it more prominent without making it larger.
Position
Position works with the scanning pattern. In left-to-right languages, the top left is read first. Put the key message and the primary action where the eye is already going, not where you hope it will go.
A worked example
The page below uses all four levers. The headline is the largest element. The button is the only strongly colored element. Whitespace separates the intro from the feature list. The headline sits at the top left.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hierarchy example</title>
<style>
body { font-family: system-ui, sans-serif; color: #222; margin: 0; }
main { max-width: 40rem; margin: 0 auto; padding: 3rem 1rem; }
h1 { font-size: 2.25rem; line-height: 1.2; margin: 0 0 1rem; }
h2 { font-size: 1.25rem; margin: 3rem 0 0.5rem; }
p, li { font-size: 1rem; line-height: 1.6; color: #444; }
.button {
display: inline-block;
margin-top: 1.5rem;
padding: 0.75rem 1.5rem;
background: #0b5fff;
color: #fff;
font-weight: 700;
text-decoration: none;
border-radius: 0.25rem;
}
</style>
</head>
<body>
<main>
<h1>Share one board with your whole team</h1>
<p>Track tasks, deadlines and files in one place.</p>
<a class="button" href="/signup">Start free trial</a>
<h2>What you get</h2>
<ul>
<li>Unlimited boards</li>
<li>Deadline reminders</li>
<li>File attachments</li>
</ul>
</main>
</body>
</html>The margin: 3rem 0 0.5rem on h2 is deliberate. The large space above the heading separates it from the button. The small space below it ties the heading to its list.
Common errors
- Too many focal points. Several large or brightly colored elements compete, and the eye has no first stop. Pick one primary element per screen area.
- Weak step between levels. Headings that are barely larger than body text do not work as scanning anchors.
- Equal spacing everywhere. If every gap is the same, nothing looks grouped. Use less space inside a group than between groups.
- Contrast used only for decoration. A bright banner ad can pull attention away from the content you care about.
- Low-contrast text. Light gray text on white looks refined, but it is hard to read and fails accessibility checks.
Checking your hierarchy
The squint test is a quick check. Blur your eyes, or apply a blur filter to a screenshot. The elements that remain visible are the ones that carry your hierarchy. If the call to action disappears, or an unimportant banner is the strongest shape, adjust size, contrast or space until the order matches your intent.
Exercise
A landing page has a large headline, a large rotating banner in bright orange, and a small gray "Sign up" link. Visitors rarely sign up. Using the four levers, describe two changes that would improve the hierarchy.
Show answer
First, reduce the competing element. Make the banner smaller or calmer in color so it no longer outranks the headline and the sign-up action. Second, raise the prominence of the sign-up action. Turn the link into a button with a strongly contrasting background, increase its size, and add whitespace around it. Placing it near the headline, in the top-left reading path, would also help. Together these changes make the sign-up action the clearest focal point after the headline.