WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Can you remove link underlines and focus indicators in PDF documents?

for

From: Philip Kiff
Date: Feb 18, 2025 9:09AM


That is super interesting to me, Steve!

Thanks so much for taking the time to figure out how the algorithm in
Adobe Reader works, explaining it to the list, and for sharing the test
file (which I received off-list because you cc'd me - the mailing list
otherwise strips out attachments, I think).

I guess I've never actually carefully thought about - or even carefully
observed (!) - the differences in how focus colour and background colour
interact with link colour in different PDF software readers.

In the sample links in the PDF you sent, I notice that most (or all?)
cases of colour contrast failures for focus indicator vs background, the
link text itself would also fail to meet colour contrast minimums for
standard foreground vs background text. So perhaps - at least with Adobe
Reader - the current algorithm should lead to a focus indicator that
meets minimum colour contrast guidelines, provided that your link text
itself also does?

Also, while checking the PDF viewers in Firefox and Chrome just now, I
don't see the "dual colour" black and white focus indicator in Chrome? I
do see a dual colour indicator in Firefox, with black then white
outlines, which as you say, will force the focus to become visible
regardless of background. When I tried to test in Chrome, all I seem to
be getting is a dotted black focus indicator, which remains the same
colour regardless of background colour. And which is therefore entirely
invisible against a black background. Though maybe my browser/system
dark mode/accessibility settings are affecting Chrome's display. I'm
testing with Windows 11, Chrome 133.0.6943.99 64-bit.

Like I say, this is all new learning for me, and very interesting, thanks.

Phil.

On 2025-02-14 3:14 a.m., Steve Green via WebAIM-Forum wrote:
> Adobe Reader automatically sets the colour of the focus indicator based on the link's background colour. This could have worked really well, but they created an incredibly stupid algorithm for doing it. The result is that in terms of WCAG conformance, the focus indicator has sufficient colour contrast against some background colours but not against others. Fortunately, you can choose background colours that you know will have sufficient contrast.
>
> The algorithm is very simple. They simple deduct the hex colour of the background from #FFFFFF to get the focus indicator colour. If the background is #E26B0A (which is a dark orange), the focus indicator will be #1D94F5, which gives a colour contrast ratio of 1.04 so the focus indicator is virtually invisible. But if the background is #FFCC99 (which is a light orange), the focus indicator is #003366, giving a contrast ratio of 8.62.
>
> I have attached a test file containing a variety of background colours that I used to verify the algorithm works the way I described above.
>
> It's worth noting that Adobe Reader calculates the focus indicator colour for individual dots in its dotted outline. The result is that some parts of the focus indicator colour will be different from other parts if the link overlays an irregular background colour such as a gradient or an image. In marginal situations, this increases the chance of at least some of focus indicator having sufficient contrast.
>
> Of course, other PDF readers will apply different focus indicator colours. In the Edge browser, the focus indicator colour varies between pure black and almost pure black depending on the background colour, so it is non-conformant against many background colours and is even worse than Adobe Reader.
>
> Chrome uses its dual colour black and white focus indicator, so it has sufficient colour contrast against all background colours. Likewise, Firefox uses its dual colour blue and white focus indicator.
>
> Steve Green
> Managing Director
> Test Partners Ltd
>
>