Sub topic 1
What Visual Hierarchy Is and Why It Matters
Prerequisites
Assume you know basic HTML, CSS selectors, custom properties, and the box model. You should also understand how headings, paragraphs, links, and buttons form a page.
Visual hierarchy is the order in which a page draws attention. It helps readers understand what matters first, what supports it, and what they can ignore for now. Designers create hierarchy with size, contrast, position, spacing, and grouping.
A strong hierarchy gives each view one clear primary focus. A landing page might emphasize its main heading and call-to-action button. A documentation page might emphasize the article title, then section headings.
Size: Bigger Elements Are Seen First
Larger elements usually attract attention before smaller ones. Use size differences to separate levels of importance. A page title should be larger than a section heading, and a section heading should be larger than body text.
Size alone does not guarantee priority. A small, bright button can compete with a large, muted heading. Treat size as one cue among several.
Building a Consistent Type Scale
A type scale is a set of text sizes with predictable steps. Consistent steps make the page feel ordered instead of arbitrary.
:root {
--step-0: 1rem;
--step-1: 1.25rem;
--step-2: 1.563rem;
--step-3: 1.953rem;
--step-4: 2.441rem;
}
body {
font-size: var(--step-0);
line-height: 1.5;
}
h2 { font-size: var(--step-2); }
h1 { font-size: var(--step-4); }Use the same scale across related pages. Adjust line height as text becomes larger or smaller so that lines remain easy to follow.
Contrast: Making Elements Stand Out
Contrast is the difference between an element and its surroundings. It can come from color, lightness, font weight, or borders. Dark text on a light background is easier to read than gray text on a slightly lighter gray background.
For normal text, target a WCAG contrast ratio of at least 4.5:1. Large text has a lower minimum of 3:1. Check contrast for buttons and other controls too.
Exercise
A page title, a secondary link, and a primary button all look equally prominent. Name one change that would improve the hierarchy.
Show answer
Increase the title size or weight, and give the primary button a filled background while keeping the secondary link quieter.