WCAG 2.2 for links
Links on colored backgrounds Every state, every criterion
A link has to stand out from the background, from the text around it, and in every state: at rest, visited, on hover and with the keyboard's focus ring. On most colored backgrounds color alone cannot do all of that, and this workbench shows why, measures each state against its own criterion, and writes the CSS that passes.
What you get
- Every state measured The link at rest, visited, on hover and focus, and its focus ring, each against the background.
- Each criterion on its own 1.4.3 for contrast, 1.4.1 for telling links from text, 1.4.11 and 2.4.13 for the focus ring.
- The room color leaves A chart of every lightness of your link's hue, and where, if anywhere, it works without an underline.
- CSS that passes A recipe for the band and its links in every state, with the nearest fixes one click away.
The workbench
Measure links on a background
Set the background, the text and the link in each state, choose how links are underlined, or open an example. Every change is measured again at once.
The workbench needs JavaScript. The worked examples below read without it.
Result
AAFails
Checks failing: 3 Checks counted: 7
| Check | Criterion | Pair | Contrast | Needs | Result |
|---|---|---|---|---|---|
| Body text on the background | 1.4.3 AA | 6.70:1 | 4.5:1 | Passes | |
| Link on the background | 1.4.3 AA | 3.71:1 | 4.5:1 | Fails | |
| Hover and focus color on the background | 1.4.3 AA | 5.49:1 | 4.5:1 | Passes | |
| Visited link on the background | 1.4.3 AA | 4.82:1 | 4.5:1 | Passes | |
| Link against the body text, without an underline | 1.4.1 A | 1.38:1 | 3:1 | Fails | |
| A cue besides color on hover and focus | 1.4.1 A | — | An underline or another cue | Fails | |
| Focus ring against the background | 1.4.11 AA | 3.71:1 | 3:1 | Passes | |
| Focus ring 2 px or thicker, at 3:1 | 2.4.13 AAA | 3.71:1 | 3:1 | Passes |
- Body text on the background
- 6.70:1
- Color alone would need
- 13.5:1
- Link colors that work without an underline
- None on this background
Every criterion passes. Nothing to change.
Underline
Underline links at rest, so color is not the only cue.
Nearest link color without an underline
None: the body text would need 13.5:1 on the background for a link color to stand apart from it.
Nearest link color, underlined
#B5D8FF 4.54:1
Nearest hover and focus color
Already passes.
Nearest visited color
No lightness of this hue gets there.
Nearest focus ring color
Already passes.
CSS for this design
.band {
background-color: #1D4ED8;
color: #FFFFFF;
}
.band a {
color: #93C5FD;
text-decoration: none;
text-decoration-thickness: 1px;
text-underline-offset: 0.2em;
}
.band a:visited {
color: #DDD6FE;
}
.band a:hover,
.band a:focus-visible {
color: #DBEAFE;
}
.band a:focus-visible {
outline: 2px solid #93C5FD;
outline-offset: 2px;
}
Worked examples
Five link designs, measured
Each design is measured at level AA for its text size. Open one in the workbench to change anything.
| Design | Background, text, link | Underline | Link on the background | Link against the text | Focus ring | Result | A fix | Workbench |
|---|---|---|---|---|---|---|---|---|
| Links on a white page | #FFFFFF#111827#2563EB | Never | 5.16:1 | 3.11:1 | 5.16:1 | Fails 1.4.1 | Underline on hover and focus | |
| A brand blue banner | #1D4ED8#FFFFFF#93C5FD | Never | 3.71:1 | 1.38:1 | 3.71:1 | Fails 1.4.3, 1.4.1 | Underline at rest and link #B5D8FF | |
| A dark footer | #111827#9CA3AF#60A5FA | On hover and focus | 6.97:1 | 1.00:1 | 6.97:1 | Fails 1.4.1 | Underline at rest | |
| A warning callout | #FEF3C7#78350F#B45309 | On hover and focus | 4.50:1 | 1.24:1 | 4.50:1 | Fails 1.4.1 | Underline at rest | |
| A green promo band | #166534#FFFFFF#FFFFFF | Always | 7.13:1 | 1.00:1 | 2.16:1 | Fails 1.4.11 | Focus ring #42C065 |
- White leaves room for color. Near-black text reaches 17.73:1 on white, more than the 13.5:1 color alone needs, so the blue link stands 3.11:1 apart from it. It still needs a cue on hover and focus, such as an underline.
- A colored band leaves none. White text on the brand blue reaches 6.70:1, so no link color can clear the blue by 4.5:1 and the text by 3:1 at once; the pale blue link is 1.38:1 from the text. Underline it.
- Hue is not contrast. In the dark footer the blue link and the gray text measure 1.00:1 against each other: only their hue differs, which many readers cannot see.
- An underline on hover comes too late. The callout's underline appears on hover, but at rest the link is told from the text by color alone, at 1.24:1.
- The focus ring needs 3:1 too. A green ring on the green band measures 2.16:1; a lighter green, #42C065, reaches 3:1.
Method
How it measures
- The body text and the link in each state, at rest, on hover and focus, and visited, are measured on the background with WCAG 2's ratio: 4.5:1, or 3:1 for large text; 7:1 and 4.5:1 at level AAA.
- Without an underline at rest, the link and the visited link are measured against the body text, which technique G183 sets at 3:1, and the link must show a cue besides color on hover and focus. An underline is that cue, and with one at rest the link is not told apart by color alone.
- The focus ring is drawn outside the link with an offset, so the background surrounds it: it must differ from the background by 3:1 (1.4.11), and at level AAA be at least 2 px thick too (2.4.13).
- The chart takes the link's hue and chroma in OKLCH and measures every lightness against both the background and the text; where both pass, a link color works without an underline.
- Each fix keeps its color's hue and chroma and moves only its lightness, by the smaller step that passes.
Why a colored band leaves no room: a link between the text and the background in lightness must clear the background by 4.5:1 and the text by 3:1. Contrast ratios multiply along that line, so the text must already reach 4.5 × 3 = 13.5:1 on the background; at level AAA it would take 7 × 3 = 21:1, which only black on white reaches.
The worked examples are recomputed by an automated test from the same code, so a figure on this page cannot drift from what the workbench measures.
Found a wrong number? Tell us.
Limits
What a measurement cannot tell you
- G183 is one way to meet 1.4.1, not the only one. An underline, an icon, a heavier weight or a border also tell a link apart without color.
- Links in menus and lists are a different case. 1.4.1 is about links inside running text; in a navigation bar, where everything is a link, there is no body text to tell them from.
- The ring is assumed to sit on the background. A ring drawn against the link's own fill, or a focus style that changes the background instead, must differ from what is next to it, which this page does not draw.
- Browsers restrict visited styles. Only colors can change on :visited, and scripts read the unvisited color for privacy; this page measures the color you set.
- Touch screens have no hover. On a phone, the cue that matters is the one at rest and in focus.
- Only flat backgrounds are measured. For links over a photo or a gradient, measure with Text on an image or Text and gradients.
In practice
Making links clear on any background
- Underline links in running text. It is the one cue that works on every background, in every theme, for every reader.
- Keep the underline light and lift it on hover. A 1 px line offset by 0.2em reads cleanly; thicken it to 2 px on hover and focus.
- On a colored band, let links share the text color. The text already passes on the band; the underline marks the link, and the color can stay calm.
- Give the focus ring its own color. White or near-black usually clears a mid-tone band by 3:1 where a tint of the band does not; offset it by 2 px.
- Check visited links and hover colors as well. A pale visited color is the state most often left failing.
The rules: 1.4.1 Use of Color, 1.4.3 Contrast (Minimum), 1.4.11 Non-text Contrast, 2.4.7 Focus Visible and 2.4.13 Focus Appearance.
Where next
Check the rest of the page
From links to every pair on a page.
- Contrast hubWhat WCAG 2.2 asks for, the maths, and the nearest passing color for any pair.
- Links patternLink text, keyboard behaviour and the code for a link that works for everyone.
- See-through colorsColors with opacity measured as the screen shows them, on any page, with fixes that keep the alpha.
- Contrast checkerOne pair in depth: APCA beside WCAG, a palette matrix and a link you can share.