Let the browser do what browsers do: a story about accessibility on Medium
Tags: a11y, design, inclusion
Published: 2020-10-23 22:42:14

<figcaption></figcaption>
</figure>

Hello, friends! Perhaps you have already heard an old web accessibility accessibility principle: developers should rely on browser [semantics](https://developers.google.com/web/fundamentals/accessibility/semantics-builtin) as much as possible. 

Maybe you have heard it in the form of [The First Rule of ARIA](https://www.w3.org/TR/using-aria/#firstrule):
> If you can use a native HTML element [HTML51] or attribute with the semantics and behavior you require already built in, instead of re-purposing an element and adding an ARIA role, state or property to make it accessible, then do so.

The rules of ARIA generally describe how to make interactive aspects of your site accessible. In this post, we're going to look at how overriding browser _styling_ defaults can also lead you astray, accessibility-wise. 

This story begins with me, reading some interesting blog posts on Medium.com, on my phone. I use the browser's built-in text magnification, because even with glasses, vision remains a challenge for me. (Specifically, I use Brave and Chrome on Android, with text magnification of 150%.) I had been noticing that link underlines on Medium posts made the words look as if they were struck out. 

<figure>
![a screenshot of a Medium post on Chrome on Android. The link underlines appear as strikeouts, about 1/4 the way up the word](https://dev-to-uploads.s3.amazonaws.com/i/njjyr32i1pim8dbzo0ei.png)
<figcaption>On Chrome on Android, this isn't a strikeout - these are misbehaving link underlines.</figcaption>
</figure>

(The story ends with me procrastinating a month to write this post, and in the meantime, Medium has actually fixed the issue. If you change your text magnification settings and go looking for it, you won't find it. <mark>Took you a while,</mark> _\*cough\* six years_ <mark>but good job, Medium!</mark> The screenshots for this piece were all collected on October 1st, 2020, and shared in two different slacks where I was trying to parse through the issue with the help of friends.) 

I opened up the same post in a browser to inspect the HTML and CSS, and was surprised: on desktop Firefox, the links were unmarked entirely! Surely someone had noticed this, right? But the misplaced underlines had been happening for me for quite a while on mobile; what was going on?

<figure>
![a medium article viewed in firefox, with the dev tools open. There are no link underlines visible in the post](https://dev-to-uploads.s3.amazonaws.com/i/tfksrmc960hp92s77wyb.png)
<figcaption>In desktop (macOS Catalina) Firefox, the link underlines have vanished completely!</figcaption>
</figure>

Eventually, with the help of folks in some tech slacks I'm in, I realized others _weren't_ seeing what I was seeing. What?!? Then I remembered I also use vision accommodations in desktop browsers. Specifically, I have a [minimum font size](https://support.mozilla.org/en-US/kb/font-size-and-zoom-increase-size-of-web-pages) set at the browser level, and all sites I visit have to display text no smaller than that font, regardless of what the developers wanted. When I turned that off, the underlines snapped back into their normal places. 

<figure>
![In mobile chrome, at 100% text magnification, the underlines are present and in their proper places](https://dev-to-uploads.s3.amazonaws.com/i/omxdd79ie7q6yrf9dw8e.png)
<figcaption>In mobile chrome, at 100% text magnification, the underlines are present and in their proper places</figcaption>
</figure>

<figure>
![In Chrome on desktop mac, with no font size overrides active, the text underlines are present and in their proper places](https://dev-to-uploads.s3.amazonaws.com/i/wexkyzwhloq596ivgnc0.png)
<figcaption>In Chrome on macOS Catalina, with no font size overrides active, the text underlines are present and in their proper places!</figcaption>
</figure>

Something you might have noticed in the browser tools of those screenshots (or you might not because the screenshot is blurry; sorry, I didn't copy out the HTML and it's gone forever now) is that Medium is doing some funny-business with the underlines. Each of the links has `text-decoration: none`, and the underline is being provided through a `background-image` which is an SVG. 

Someone in one of the slacks I was documenting my perplexity in pointed me to this post: ["Crafting Link Underlines on Medium"](https://medium.design/crafting-link-underlines-on-medium-7c03a9274f9), posted on Medium's official design blog way back in 2014. In this post, a designer at Medium documented the design team's frustration with browser built-in underlines, and what considerations went in to building "better" underlines. The frustration seems to be that the underlines were a bit bolder than the design team would like; to my non-designer (and admittedly, lower-than-average vision) eyes, a comparison of the previous and new-then underlines look very similar, and the previous ones certainly don't offend me enough that I'd go to much effort to change them. The author went on to document implementations that the team had considered and rejected, and the one they chose: some code that looked suspiciously like what I was seeing in the developer tools of my browser on October 1, 2020.

Here is where I get a little snarky, because I was going down a deep rabbit hole to figure out why these underlines behaved so poorly for me, then was a bit ragey to find it was yet another broken thing resulting from site builders not anticipating & accounting for the assistive technology I use. And then, I opened this post, from Medium, about the exact thing that has been causing this problem for 6 years now, and it started like this: 

> How hard could it be to draw a horizontal line on the screen?

_insert very snarky comment right about here_

Another standout line, that many others before me have highlighted, goes like this:

> Web design always seemed like this, too: finding convoluted, “dirty” solutions to often simple problems, using a very limited set of tools. 

_insert mirthless laugh here_ 

To be fair to the Medium design team, they _did_ consider some accessibility issues in the implementation they eventually chose. 

Their list of criteria for the final design includes these lines: 

> We adjust the sizes of fonts for tablets and mobile phones.
> We fall back to a default system font for when we decide that our type doesn’t support all the characters in a given language.
> Some people zoom in (or zoom out) their browsers.
> Some people use uncommon browsers.

People _do_ zoom in & out their browsers, and good site designs should account for that, and not break. But some people, like me, find that browser zoom is not the best solution for reading text better. If you zoom your browser, you might need to adjust the zoom level on every page you visit. Browser zoom also means that ads and the images accompanying posts have also gotten bigger, so you're going to need to scroll more. (In my case, I can typically see images just fine, except for tiny profile images. I really just need the text to be bigger, and when it's already huge, to not get any bigger. One might say... to be always bigger than a minimum size.)

So here we have a case where a design/dev team wanted to customize the styling of a built-in browser [affordance](https://developers.google.com/web/fundamentals/accessibility/semantics-builtin#affordances). And they _did_ want to ensure the thing they were building would still be accessible. But, they failed to account for one particular way of making the web accessible that users with low vision might use, and made their experience much worse. (It's distracting that many of the words of some posts appear to be crossed out, as in mobile browsers, and it's even more confusing to have links not visually indicated at all, as in desktop Firefox.) 

How has Medium fixed the issue? Took out most of their custom `background-image` stuff, basically. Now they have a class on all their links, adding `text-decoration: underline`. _Wait Cassey, you said that's built-in, why do they need that?_ Only because when cleaning up their legacy code that did the `background-image` stuff, they didn't also axe the CSS that did `a { text-decoration: none }`, which removes that handy browser built-in.

You can [read more about link underlines](https://adrianroselli.com/2016/06/on-link-underlines.html) in this post from [@aardrian](https://twitter.com/aardrian) who does not (in a 2016 blog post, with a few updates since then) take for granted, like I do, that link underlines are obviously good and important, and considers a whole host of reasons people like and dislike them, and what is best for accessibility. (Spoiler, they conclude link underlines are best.)