Sub topic 2
Designing Links That Stand Out from Text
This chapter assumes basic HTML attributes, CSS selectors, pseudo-classes, and browser developer tools. A link is an element that takes the user to another location. Its visual design should make that destination and navigation purpose clear.
Designing links that stand out from text
Inline links must be recognizable without depending on color alone. An underline is a reliable signifier because it remains visible for users with color-vision differences. Standalone links can use stronger spacing, weight, or button-like styling, but they should still behave as navigation.
Use meaningful link text. “Read the accessibility guide” tells users what will happen. “Click here” does not.
<main>
<p>
Read the
<a href="/guides/accessibility">accessibility guide</a>
before continuing.
</p>
<p><a class="action-link" href="/account">View your account</a></p>
</main>
<style>
a {
color: #1d4ed8;
text-decoration: underline;
text-decoration-thickness: 1px;
text-underline-offset: 0.15em;
}
.action-link {
display: inline-block;
font-weight: 600;
}
</style>The text color and underline should have enough contrast against the background. Do not remove the underline from inline links unless another persistent visual cue clearly distinguishes them from nearby text.
Hover, active and visited states
State changes confirm interaction:
:hoverresponds while a pointer is over the link.:activeappears while the link is being pressed.:visiteddistinguishes destinations the browser has already opened.
Keep these changes noticeable but do not change layout. A darker color and thicker underline are usually enough.
a:hover {
color: #1e3a8a;
text-decoration-thickness: 2px;
}
a:active {
color: #172554;
}
a:visited {
color: #6d28d9;
}The visited color must still meet contrast requirements. Do not use color alone to communicate an error, warning, or unavailable destination.
Focus indicators for keyboard users
Keyboard users move through links with the Tab key. :focus-visible displays an outline when focus needs to be communicated, without adding an outline after every pointer click.
a:focus-visible {
outline: 3px solid currentColor;
outline-offset: 3px;
}Never set outline: none without replacing it with a clear, high-contrast indicator. Test focus against every background where the link appears.
Exercise
What should an inline link retain even when its color changes for hover or visited states?
Show answer
It should retain a persistent cue such as an underline, so users do not need color alone to identify it.