Skip to content
easeweb
Search topics

Focus states shown only by a change of colour

The outline is removed and focus only turns a link's text blue, or gives it a pale fill, the same as hover: too close to the colour it had to stand out.

WCAG 2.2
SC 1.4.1A
Required by
Section 508 · EN 301 549 (EU)
Broken a:focus { color: #1a4fd0; outline: none; }
The accessibility problem illustrated: Colour vision:Which link am I on?
01

The problem

People who can't tell the two colours apart can't find which link keyboard focus is on

02

Try it

Press Tab down the account links, then turn on Greyscale and try again

  • Broken 1: focus only turns the link’s grey text blue, 1.24:1 apart. In greyscale, the focused link looks like the rest.

  • Broken 2: focus only gives the link a pale blue fill, 1.22:1 against the white. Look for it on a dim screen.

  • Apply a fix. Tab down the links again, in colour and in greyscale: the focused one stands out in both.

Broken Can you fix this?

Orders

You have no orders yet.

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Show focus with more than a faint change of colour

Before

The link text turns brand blue

<nav class="account-nav" aria-label="Your account">  <ul>    <li>      <a href="/orders">Orders</a>    </li>    <li>      <a href="/saved">Saved items</a>    </li>    <li>      <a href="/addresses">Addresses</a>    </li>    <li>      <a href="/payment">Payment methods</a>    </li>  </ul></nav>
What is wrong3 points
  • The outline is removed, and focus only turns the text from #4d4d4d to #1a4fd0.
  • The two colours are 1.24:1 apart, so the change is in hue alone.
  • In greyscale, or to someone who doesn't see the blue, the focused link looks like the others.
After

A focus ring beside the colour

<nav class="account-nav" aria-label="Your account">  <ul>    <li>      <a href="/orders">Orders</a>    </li>    <li>      <a href="/saved">Saved items</a>    </li>    <li>      <a href="/addresses">Addresses</a>    </li>    <li>      <a href="/payment">Payment methods</a>    </li>  </ul></nav>
How it is fixed3 steps
  1. Keep the blue text on hover and on focus: the design's colour change stays.
  2. Draw a 2-pixel outline in the brand blue on :focus-visible, 2 pixels outside the link. It is 6.83:1 against the white page, and it is a shape, so it shows whatever colours a person sees.
  3. Use :focus-visible rather than :focus, so a mouse click doesn't draw the ring.

This fixes both Befores and passes 1.4.1. The same outline goes on the pale fill version: keep the fill, and add the ring around it. A contrast theme keeps the outline and draws it in its own colour.

04

Design ideas

Focus can keep a quiet look and still show without colour

Four more ways to draw focus on the same account links. Press Tab through each: two add a shape, and two change only colour.

In the design file

  • Draw each link focused beside the same link at rest, and name what changes besides colour, such as a bar, a mark, an outline or an underline.
  • Where focus changes only a colour, write the ratio between the colour before and after, at least 3:1. The example’s grey to blue is only 1.24:1.
  • Look at the focused frame in greyscale. If the focused link looks like the others, add a shape.
  • Draw focus apart from hover, since the pointer shows where the mouse is and only the focus style shows where the keyboard is.

Passes

  • Bar along the edge A 4px bar in the brand blue appears along the focused link’s start edge, 6.83:1 against white, and the words turn blue beside it. The bar is a shape, so it shows in greyscale, and drawn as a border it stays in a Windows contrast theme.
  • Chevron that appears A small chevron in the text colour appears before the focused link’s words. Keep its space empty at rest, so the words don’t move when it appears. It is a new shape, not a new colour, so nothing depends on seeing the blue.

Fails

  • The other links dimWCAG 1.4.1 When focus enters the list, every other link fades to 60% and the focused one stays #4d4d4d. The faded grey is #949494, only 2.79:1 from it, so the one difference is a lightness under 3:1, and nothing else marks the link.
  • Gradient textWCAG 1.4.1 Focus fills the words with a purple to blue gradient, #6d28d9 to #1a4fd0. Both ends are almost as dark as the grey they replace, 1.19:1 and 1.24:1 from #4d4d4d, so in greyscale the focused link looks the same as the others.
05

Verify the fix

4 checks, no mouse.

Test with: Keyboard, Contrast measurement, Colour vision simulation, Forced colors

0 of 4 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the theme's colours or shared component styles change.

Limits

This is a starting pattern, not a guarantee for every application. The colours are examples; measure your own before and after colours on your real surfaces. A focus style that passes 1.4.1 can still be hard to find if it is thin or faint, and 2.4.13 Focus Appearance, at Level AAA, asks for more, as focus rings too thin or faint to spot explains. Test the complete journey with people who rely on seeing focus.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

EaseWeb service

Fixed it? Keep it from coming back.

I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.

See the service