Sub topic 1
What visual hierarchy is and why it matters
Visual hierarchy is the order in which a page's elements draw attention. It tells readers what matters most, what comes next, and what can wait. Every page has a hierarchy, whether you designed one or not. This chapter gives you the working model for the rest of the tutorial.
Prerequisites
This chapter assumes you have:
- Basic HTML structure: headings, paragraphs, links, and buttons.
- Basic CSS: selectors, properties, custom properties, and the box model.
- Some familiarity with how a typical web page is laid out, such as a header, a main area, and a footer.
The working model
Readers do not read a page from the first word to the last. They scan it, pick out a few elements, and decide whether to keep going. Hierarchy controls what they pick out first.
Three cues create most of that emphasis:
- Size: larger elements are noticed before smaller ones.
- Contrast: an element that differs from its surroundings in color, lightness, or weight stands out.
- Position: elements near the top, or in the places people look first, get seen earlier.
A fourth factor supports these three. Spacing and proximity group related items, so readers see one cluster instead of five separate things. Later chapters cover each cue in turn. Here you only need to see that they work together.
The result is a ranking. Each element is primary, secondary, or tertiary, and the design should make that ranking visible.
Why it matters
A clear hierarchy does three jobs.
- It speeds up scanning. Readers find the headline, the main action, and the section they want without reading everything.
- It shows structure. A heading that is larger and bolder than the text below it signals that the text belongs to it.
- It directs action. If a page has one important button, the hierarchy should make that button the easiest thing to spot.
When hierarchy is missing, readers must work to decide what is important. Many leave instead.
A flat page versus a ranked page
The first example gives every element the same weight. Nothing tells the reader where to start.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hierarchy demo</title>
<style>
body { font-family: sans-serif; font-size: 1rem; }
.flat * { font-size: 1rem; font-weight: 400; color: #333; }
.ranked h1 { font-size: 2.4rem; line-height: 1.15; margin: 0 0 0.5rem; }
.ranked p { color: #555; margin: 0 0 1rem; }
.ranked a { font-weight: 700; }
</style>
</head>
<body>
<section class="flat">
<h1>Spring sale</h1>
<p>Save on all plans until Friday.</p>
<a href="/plans">See plans</a>
</section>
<hr>
<section class="ranked">
<h1>Spring sale</h1>
<p>Save on all plans until Friday.</p>
<a href="/plans">See plans</a>
</section>
</body>
</html>The markup is the same in both sections. In the second one, CSS makes the heading about 2.4 times larger and makes the link bold, so the order of importance is clear: heading, supporting text, action. The HTML heading levels carry the same ranking for assistive technology, so the visual and structural rankings should agree.
Common errors
- Everything emphasized. If every element is large, bold, or brightly colored, none of them stands out. Emphasis only works by comparison.
- Several competing focal points. Two large banners and three bright buttons in one view force the reader to choose.
- Hierarchy by decoration only. Styling a
<div>to look like a heading gives sighted users a ranking that screen reader users never receive. Use real heading elements and style them. - Weak differences. A 16px body and an 18px heading look almost the same. Differences must be large enough to see at a glance.
- Ignoring context. A hierarchy that works on a wide desktop screen can fall apart on a phone, where elements stack and the order changes.
What comes next
The next chapters take the cues one at a time. You will start with size and a consistent type scale, then move to contrast, position, and spacing. After that you will combine them, check that visual order matches the DOM order, adapt the result to different screen sizes, and evaluate it.
Exercise
A landing page has a large banner, a bright orange "Buy now" button, a bright green "Free trial" button, and a large animated logo, all visible at once. Which common error is this, and what is one fix?
Show answer
Several competing focal points. Each element is emphasized with size or strong color, so the reader has no clear first target. Pick the one primary action, for example "Free trial", and give it the strongest emphasis. Reduce the others by making the second button an outline style, shrinking the logo, and removing the animation.
Exercise
Why is it a problem to style a <div> with a large bold font so it looks like a heading, instead of using an <h2>?
Show answer
The ranking is visible only to sighted users. Screen readers and other tools rely on real heading elements to describe the page structure, so they would not announce the <div> as a heading. Use <h2> and style it with CSS.