Menu

I weighed every character on our site by its contrast ratio, and 39.5 per cent of them fail
📰

I weighed every character on our site by its contrast ratio, and 39.5 per cent of them fail

DEV Community: css·Daniel Pertu·about 9 hours ago
#FOTgiphK
#devtocss#devto#dev#fafafa#characters
Reading 0:00
15s threshold

When I audited all 38 pages of our site for accessibility a few weeks ago, the contrast section counted elements: 546 links at 2.53:1, a focus ring at 1.82:1. That is how every tool I know of reports it, including the ones built into the browser. An element is a row, and a row is a row whether it holds one word or two hundred.

That bothered me, because a reader does not read elements. So I ran it again weighted by character.

Method

Playwright, the 38 URLs in our sitemap , and a walk over every text node in the body. For each node I took the computed color of its parent, then climbed the tree until I found an ancestor with a background whose alpha is over 0.5, which is the colour the text is actually drawn on rather than the one I assumed it was on.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.