Sub topic 12
Check contrast, text size, and structure
This chapter assumes you have a high-fidelity mockup with a type scale, a color palette, and the semantic wireframe structure from earlier chapters. You should know basic HTML and CSS terms. The goal is to catch accessibility problems in the design file, where fixing them costs a few minutes. Fixing them after build costs far more.
Why check at the mockup stage
Color, type size, and heading order are all decided in the mockup. If the accent color fails a contrast test, every button and link built from it fails too. Checking now means you change one token instead of hunting through finished pages.
Three checks cover most of the risk: color contrast, text size, and page structure.
Check color contrast
Contrast ratio compares the brightness of text and its background. It runs from 1:1 (no difference) to 21:1 (black on white). The WCAG 2.2 guidelines (Web Content Accessibility Guidelines) set these minimums at level AA:
| Content | Minimum ratio |
|---|---|
| Body text and small text | 4.5:1 |
| Large text (24px, or 18.66px bold) | 3:1 |
| Icons, input borders, focus outlines | 3:1 |
Test every text and background pair in the mockup. Use a contrast checker, or the contrast plugin for your design tool. Pay attention to text over photos, light gray placeholder or caption text, and white text on the accent color.
With the palette from the earlier chapters, the pairs look like this:
| Pair | Ratio | Result |
|---|---|---|
| `#1a1a1a` on `#ffffff` | about 17:1 | Pass |
| `#ffffff` on `#0b5fff` | about 5.5:1 | Pass for button text |
| `#9a9a9a` on `#ffffff` | about 2.8:1 | Fail for body text |
Ratios are approximate. Confirm exact values with your checker. If a pair fails, darken the text or change the background. Do not rely on the checker alone for text over images. Place a solid or semi-opaque layer behind the text, then test against the darkest and lightest parts of the photo.
Also check that color is never the only signal. A link that differs from body text only by hue fails for color-blind users. Add an underline, or use an icon plus a label for error states.
Check text size
WCAG does not set a minimum font size, but practice does. Aim for body text of at least 16px (1rem). Define sizes in rem so users who raise their browser default get larger text. The type scale from the earlier chapter already does this.
Check these points in the mockup:
- Body text is 1rem or larger, and captions are not smaller than about 0.875rem.
- Line length is roughly 45 to 75 characters.
- Line height is about 1.5 for body text.
- Text still fits when scaled to 200%. Buttons and cards must grow, not clip.
Check structure
A screen reader user navigates by headings, landmarks, and links. The mockup should map cleanly to the semantic skeleton from the wireframe chapter.
<body>
<header>
<a href="/">Brand</a>
<nav aria-label="Main">
<a href="/products">Products</a>
<a href="/pricing">Pricing</a>
<a href="/contact">Contact</a>
</nav>
</header>
<main>
<section class="hero">
<h1>One clear promise for the visitor</h1>
<p>A short supporting sentence.</p>
<a class="button" href="/signup">Get started</a>
</section>
<section class="features">
<h2>Key benefits</h2>
</section>
</main>
<footer>
<p>Contact and legal links</p>
</footer>
</body>Verify the following against the mockup:
- The page has one
h1, and headings step down without skipping levels (h1, thenh2, thenh3). - Heading size reflects rank, but rank comes from the heading level, not from size alone.
- Visual reading order matches the order in the source, so keyboard focus moves top to bottom, left to right.
- Every interactive element has a visible focus style, and you have drawn it in the mockup.
- Link and button text makes sense alone. "Get started" works, "Click here" does not.
- Touch targets are at least 24px square, and 44px is a safer goal on mobile.
A repeatable pass
Common errors
- Testing only the default state. Hover, focus, disabled, and error states need their own checks.
- Checking contrast on the white artboard but not on the colored footer or the hero image.
- Choosing a heading level for its size. Use the correct level and style it with CSS.
- Removing the focus outline without a replacement.
Exercise
A secondary button uses white text (#ffffff) on a light blue background (#7fb0ff), and the checker reports 2.2:1. Name the minimum ratio for this text, and give two ways to fix it.
Show answer
Normal-size button text needs at least 4.5:1 at level AA. Fix it by darkening the background (for example toward the accent #0b5fff), or by switching to dark text such as #1a1a1a on the light blue. If you change the shared color, update the design token so every use stays consistent.
Exercise
A mockup has a page title styled at 2.5rem and a section title that looks larger than an h2 because the designer wants it to stand out. What structure rule should you check, and how do you keep the visual choice?
Show answer
Check that the page has one h1 and that headings do not skip levels. Keep the section title as an h2 for structure, and apply a larger font size to it with CSS. Visual size and heading level are set separately.