On this page
Links can disappear into surrounding text when their only distinguishing feature is color, especially when Windows replaces author-defined colors with a user's contrast-theme palette. Accessible links in forced colors mode need a recognizable shape or decoration, plus a visible keyboard focus indicator.
This guide shows how to style inline and navigation links without overriding user-selected system colors, and how to review them with a keyboard and Windows contrast themes.
Key Takeaways
- Underline inline links so readers do not have to distinguish them by color alone.
- Make navigation links recognizable as interactive even when their colors are replaced.
- Use a visible outline for keyboard focus; do not rely solely on a box shadow.
- Let forced-colors mode apply system colors rather than opting out with
forced-color-adjust: none. - Test with actual contrast themes and keyboard navigation. The examples and test procedure below were not executed or verified in a browser for this article.
Why color alone is not enough
WCAG's Use of Color criterion, 1.4.1, requires that color not be the only visual means of conveying information, including indicating an interactive element. An underline is a straightforward additional cue for a link in a paragraph. It remains useful when users have difficulty distinguishing colors or when a forced-colors palette changes them.
Navigation links may be recognizable from their placement and grouping, but those cues are not always obvious. Underlining them is a simple choice when there is any doubt. Also provide a visible keyboard focus indicator: WCAG 2.4.7 addresses focus visibility, while non-text contrast requirements can apply to visual information needed to identify a control or its state.
This article could not consult the current WCAG documentation in this run. Check the applicable WCAG version and success criteria for your project, including their full conditions and exceptions.
Advertisement
Style inline and navigation links
The following example uses ordinary anchors, which are keyboard-focusable when they have an href. It keeps link underlines and adds an outline for focus. The fragment destinations are included so the example can be saved as an HTML file and tried locally.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Link visibility example</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<nav class="site-nav" aria-label="Primary">
<a href="#overview">Overview</a>
<a href="#details">Details</a>
</nav>
<main class="content">
<section id="overview">
<h1>Overview</h1>
<p>Read the <a href="#details">details of this example</a>.</p>
</section>
<section id="details">
<h2>Details</h2>
<p>Use the navigation links to move between sections.</p>
</section>
</main>
</body>
</html>
Save this CSS as styles.css beside the HTML file:
/* Keep a non-color cue for both inline and navigation links. */
.content a:any-link,
.site-nav a:any-link {
text-decoration-line: underline;
text-underline-offset: 0.15em;
}
/* Fallback: show focus for all focus methods. */
.content a:focus,
.site-nav a:focus {
outline: 2px solid currentColor;
outline-offset: 3px;
}
/* Where supported, avoid showing the ring for focus that is not
considered keyboard-visible by the browser. */
.content a:focus:not(:focus-visible),
.site-nav a:focus:not(:focus-visible) {
outline: none;
}
@media (forced-colors: active) {
/* Use a system color rather than forcing an author-chosen color. */
.content a:focus,
.site-nav a:focus {
outline-color: Highlight;
}
}
The CSS does not assign a fixed link text color or disable forced-color adjustment. In forced-colors mode, the browser and system can therefore apply their palette. Highlight is a system color, but it is still important to check the outline against the actual background in each theme; do not assume every combination will be sufficiently distinct.
The focus rule initially applies to all focused links. In browsers that support :focus-visible, the later rule removes it when the browser determines a visible indicator is not needed. In browsers that do not support that selector, the earlier focus outline remains as a fallback. Check that existing site styles do not override these rules and that containers do not clip the outline.
Review decorative link styles
Some common treatments become ambiguous when colors or effects change:
- Color-only inline links: removing the underline can make a link look like ordinary text. Restore a persistent underline rather than adding it only on hover.
- Subtle borders or background fills: a pale background or thin border may disappear or lose contrast when the palette changes. Do not make it the only cue that navigation text is clickable.
- Box-shadow focus rings: box shadows may be suppressed in forced-colors mode. Use an outline or another indicator that remains visible, then test it.
- Icon-only links: retain an accessible name and a visible focus indicator. Check that the icon remains visible when colors change; an icon alone may not communicate its destination clearly.
- Underlining non-link text: decorative underlines on ordinary text can make actual links harder to identify.
Advertisement
Test keyboard navigation and Windows contrast themes
No browser or operating-system test was performed for this article, so there are no observed results or verified current browser versions to report. Use the following procedure to create a record for your own release; do not treat an unfilled record as a pass.
- On a Windows test machine, enable a contrast theme in system accessibility settings. Settings labels can differ by Windows version. Try at least one dark and one light theme available on that machine.
- Open the page in each browser your project supports. Record the Windows version, browser name and version, and theme for every run. If browser emulation is used as an additional check, label it as emulation rather than an operating-system theme test.
- Press
Tabfrom the start of the page andShift+Tabto move backward. Check that each link can receive focus, that the focus order makes sense, and that the indicator remains visible without being clipped. - Inspect inline and navigation links before hover or focus. Confirm that they are distinguishable from nearby text without relying on their color. Activate links with
Enterand confirm that they reach the intended destination. - Check hovered, focused and visited links where applicable. Review the page at increased zoom and with text wrapping, including links near the edges of containers.
- Record failures, fix them, and repeat the affected checks in each theme and browser.
A useful test record includes these fields:
| Windows version | Browser and version | Contrast theme | Inline and navigation links identifiable? | Keyboard focus visible? | Notes |
|---|---|---|---|---|---|
| Record after testing | Record after testing | Record after testing | Pass/fail after testing | Pass/fail after testing | Include clipping, contrast, or navigation issues |
Automated checks can help find some issues, but they cannot replace this visual and keyboard review. If a design must meet a particular WCAG conformance target, assess the relevant contrast and focus criteria rather than relying only on a subjective pass.
Common Mistakes
- Removing underlines globally. A navigation menu may still look usable while links embedded in paragraphs become difficult to find.
- Removing outlines without a replacement. Keyboard users need to see which link has focus. A hover-only treatment does not provide that information.
- Using
forced-color-adjust: noneas a shortcut. It can prevent content from following the user's chosen palette and leave text or controls difficult to see. Reserve any exception for a specific, tested need. - Testing only one palette or browser. A visible indicator in one combination does not establish that it works in another.
- Assuming a focus ring guarantees contrast. Check the indicator against its surroundings, including when links wrap or sit on different backgrounds.
Best Practices
Keep semantic anchors, persistent link cues, and a focus style that survives color substitution. Prefer system colors in forced-colors-specific rules when a color must be specified, and otherwise allow the browser to apply the user's palette. Review the actual page, including inherited styles, overlays and overflow clipping—not just an isolated component.
Conclusion
Underline links, preserve a clear keyboard focus indicator, and avoid suppressing the user's forced-colors palette. Then document real keyboard and contrast-theme tests for the browsers and Windows versions your audience uses.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.