Introduction to Web Accessibility (A11Y)
Tags: a11y, webdev, aria
Published: 2022-03-18 17:24:09

<!-- wp:paragraph -->
<p>If you’ve come across this article but haven't heard about web accessibility (often shortened to "A11Y") before, that's okay. We're all learning at different speeds and come across new things all the time. That said, accessibility is a critical component of any frontend engineer's responsibilities. We implore you to explore what that means, not just in this blog post but beyond with your teams and communities.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>First, let's define what "accessibility" is. Accessibility in engineering is <a href="https://dl.acm.org/doi/10.1145/2596695.2596719">"the process of creating products that are usable by people with the widest possible range of abilities."</a></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>One example of accessibility is the needs of blind or low-vision users. They may rely on <a href="https://www.afb.org/blindness-and-low-vision/using-technology/assistive-technology-products/screen-readers">screen readers</a> or other assistive technologies, which allows them to navigate their computer with their other senses. These methods may be used in tandem with the visual experience for some or used independently to navigate their computer auditorily or tactilely.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Another example is users with limited mobility who utilize specialty hardware, such as buttons, to trigger different behaviors on their machine.</p>
<!-- /wp:paragraph -->

<!-- wp:quote -->
<blockquote class="wp-block-quote"><p>If you're a visual learner who would like to see some short-and-quick workflows from users like this, <a href="https://www.youtube.com/watch?v=XB4cjbYywqg">one of Apple's ads</a> displays a few use cases that proper accessibility support can enable.</p></blockquote>
<!-- /wp:quote -->

<!-- wp:paragraph -->
<p>Something to keep in mind is that these disabilities may not be permanent. For instance, if you fall and break your arm, you may be only using one arm while healing. Likewise, there are situational impairments as well. If you're holding a cup of coffee in one hand, you'll only be using the other for device usage. Here's a chart that outlines a few more of these examples:​</p>
<!-- /wp:paragraph -->

<!-- wp:table -->
<figure class="wp-block-table"><table><thead><tr><th></th><th><strong>Permanent</strong></th><th><strong>Temporary</strong></th><th><strong>Situational</strong></th></tr></thead><tbody><tr><th scope="row">Touch</th><td><img class="wp-image-1824" style="width: 150px;" src="https://coderpad.io/wp-content/uploads/2021/06/one_arm.png" alt=""><br>One arm</td><td><img class="wp-image-1825" style="width: 150px;" src="https://coderpad.io/wp-content/uploads/2021/06/arm_injury.png" alt=""><br>Arm injury</td><td><img class="wp-image-1826" style="width: 150px;" src="https://coderpad.io/wp-content/uploads/2021/06/new_parent.png" alt=""><br>New parent</td></tr><tr><th scope="row">See</th><td><img class="wp-image-1827" style="width: 150px;" src="https://coderpad.io/wp-content/uploads/2021/06/blind.png" alt=""><br>Blind</td><td><img class="wp-image-1828" style="width: 150px;" src="https://coderpad.io/wp-content/uploads/2021/06/cataract.png" alt=""><br>Cataract</td><td><img class="wp-image-1829" style="width: 150px;" src="https://coderpad.io/wp-content/uploads/2021/06/distracted_driver.png" alt=""><br>Distracted driver</td></tr><tr><th scope="row">Hear</th><td><img class="wp-image-1830" style="width: 150px;" src="https://coderpad.io/wp-content/uploads/2021/06/deaf.png" alt=""><br>Deaf</td><td><img class="wp-image-1831" style="width: 150px;" src="https://coderpad.io/wp-content/uploads/2021/06/ear_infection.png" alt=""><br>Ear infection</td><td><img class="wp-image-1832" style="width: 150px;" src="https://coderpad.io/wp-content/uploads/2021/06/bartender.png" alt=""><br>Bartender</td></tr><tr><th scope="row">Speak</th><td><img class="wp-image-1833" style="width: 150px;" src="https://coderpad.io/wp-content/uploads/2021/06/non_verbal.png" alt=""><br>Non-verbal</td><td><img class="wp-image-1834" style="width: 150px;" src="https://coderpad.io/wp-content/uploads/2021/06/laryngitis.png" alt=""><br>Laryngitis</td><td><img class="wp-image-1835" style="width: 150px;" src="https://coderpad.io/wp-content/uploads/2021/06/heavy_accent.png" alt=""><br>Heavy accent</td></tr></tbody></table></figure>
<!-- /wp:table -->

<!-- wp:paragraph -->
<p>​</p>
<!-- /wp:paragraph -->

<!-- wp:quote -->
<blockquote class="wp-block-quote"><p>Microsoft originally created this chart as part of their <a href="https://download.microsoft.com/download/b/0/d/b0d4bf87-09ce-4417-8f28-d60703d672ed/inclusive_toolkit_manual_final.pdf">Inclusive Toolkit</a> manual</p></blockquote>
<!-- /wp:quote -->

<!-- wp:paragraph -->
<p>Creating an application that's accessible means that you're making a better experience for <em>all</em> of your users.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In addition to both moral and financial incentives (by opening the door to more users), many organizations have a legal requirement to meet accessibility. U.S. government software is subject to <a href="https://www.section508.gov/manage/laws-and-policies">Section 508</a>, which requires compliance to the <a href="#wcag">Web Content Accessibility Guidelines (also known as WCAG, which we'll touch on later)</a>. Likewise, private US companies may be subject to compliance due to the "Americans with Disabilities Act" (shortened to "ADA"). The U.S. isn't the only country with these requirements, either. According to<a href="https://www.w3.org/WAI/policies/"> WCAG's reference page for various legal laws</a>, there are at least 40 such laws in place around the world.</p>
<!-- /wp:paragraph -->

<!-- wp:quote -->
<blockquote class="wp-block-quote"><p>Please note that we are <em>not</em> giving legal advice. This article is simply meant for educational purposes for individuals. Consult legal authorities for the appropriate jurisdiction</p></blockquote>
<!-- /wp:quote -->

<!-- wp:paragraph -->
<p>Accessibility isn't a pure science, however. If you aren’t a user of assistive technology, this may be an abstract idea at first. However, think of it like this: the colors an app uses or a button's visual placement may convey different messages and meanings depending on their context. This same problem applies to users of screen-readers and other accessible tech as well, just with different constraints. If the screen is visually cluttered, the content may be more difficult to read. Likewise, different accessibility methods will lead to different experiences for users of assistive technology. In both of these scenarios, there may not be objectively correct answers - some may prefer a button placed visually to the left, while others might advocate for it on the right. Similarly, how something is read using a screen reader may make sense to some, but might be confusingly expressed to others.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":1} -->
<h1 id="wcag">Sensible Standards</h1>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>While accessibility has some levels of subjectivity, it's important to note that there <em>are</em> standards surrounding web application's accessibility support. <a href="https://www.w3.org/WAI/">"Web Content Accessibility Guidelines"</a> (shortened to "WCAG") are guidelines to follow when considering your app's accessibility. These guidelines are published by a subgroup of the <a href="https://www.w3.org/">World Wide Web Consortium</a> (shortened to "W3C"), the main international standards organization for the Internet. WCAG acts as the de-facto standard for accessibility guidelines.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>There are different scales of accessibility as well. <a href="https://www.w3.org/WAI/WCAG2AA-Conformance">WCAG includes three different levels of conformance</a>:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>Level A is the minimum level.</li><li>Level AA includes all Level A and AA requirements. Many organizations strive to meet Level AA.</li><li>Level AAA includes all Level A, AA, and AAA requirements.</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>Meeting AA requirements is typically seen as a good commitment to accessibility, but AAA will open more doors to your users and is the gold standard for accessible user experience.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Far from a comprehensive list, A requires:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><a href="https://www.w3.org/TR/WCAG21/#non-text-content">Non-text content to have alternative text</a></li><li><a href="https://www.w3.org/TR/WCAG21/#pause-stop-hide">Automatically moving elements (such as GIFs) must be able to be paused</a></li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>Meanwhile, AA covers things like:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>Screen reader experience</li><li><a href="#contrast">Minimum contrast guidelines</a></li><li><a href="#font-resize">Text resize support</a></li><li><a href="https://www.w3.org/TR/WCAG21/#captions-live">Video captions</a></li><li><a href="#keyboard">Basic support for keyboard navigation</a></li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>Finally, AAA includes support for:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><a href="https://www.w3.org/TR/WCAG21/#contrast-enhanced">Enhanced contrast</a></li><li><a href="https://www.w3.org/TR/WCAG21/#animation-from-interactions">Reduced/restricted animations</a></li><li><a href="https://www.w3.org/TR/WCAG21/#sign-language-prerecorded">Video sign language support</a></li><li><a href="#keyboard">Full website functionality with keyboard</a></li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>Interested in reading the full list? <a href="https://www.w3.org/WAI/WCAG21/quickref/">Read the quick reference to WCAG 2.1</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":1} -->
<h1 id="html-semantic-tags">Smartly using Semantic HTML Tags</h1>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>One of the easiest things you can do for your application's accessibility is to use semantic HTML tags.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Let's say we have HTML to display fruits in a list:</p>
<!-- /wp:paragraph -->

<!-- wp:code {"language":"xml"} -->
<pre class="wp-block-code"><code>&lt;!-- Inaccessible --&gt;
&lt;div&gt;
    &lt;div&gt;Orange&lt;/div&gt;
    &lt;div&gt;Banana&lt;/div&gt;
    &lt;div&gt;Grapefruit&lt;/div&gt;
&lt;/div&gt;</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>While this will display the contents, and you may be able to use CSS to add styling to make this look like a list, the browser has no way of knowing that this is a list. This is reflected in how screen readers read that HTML output.​​</p>
<!-- /wp:paragraph -->

<!-- wp:video {"id":1838} -->
<figure class="wp-block-video"><video controls src="https://coderpad.io/wp-content/uploads/2021/06/div.mp4"></video><figcaption>Voiceover reading of the content above</figcaption></figure>
<!-- /wp:video -->

<!-- wp:paragraph -->
<p>Likewise, search engine crawlers won't know that this is a list. If you're only using <code>div</code> tags as far as Google's concerned, you have no lists, no headings, nothing. This makes the page significantly less engaging and therefore rank more poorly.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Let's compare that to using the correct HTML tags for a list.</p>
<!-- /wp:paragraph -->

<!-- wp:code {"language":"xml"} -->
<pre class="wp-block-code"><code>&lt;!-- Accessible --&gt;
&lt;ul aria-label="Fruits"&gt;
    &lt;li&gt;Orange&lt;/li&gt;
    &lt;li&gt;Banana&lt;/li&gt;
    &lt;li&gt;Grapefruit&lt;/li&gt;
&lt;/ul&gt;</code></pre>
<!-- /wp:code -->

<!-- wp:video {"id":1839} -->
<figure class="wp-block-video"><video controls src="https://coderpad.io/wp-content/uploads/2021/06/semantic.mp4"></video><figcaption>Voiceover reading of the content above</figcaption></figure>
<!-- /wp:video -->

<!-- wp:paragraph -->
<p>As you may be able to hear, this screen reader is now able to read out that it's a list and its name. It makes navigation of that list easier for those users by allowing them to quickly skip to the next list item and hear the index of an item in the list.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Not only does this enhance the experience of assistive technology users browsing your list, but because search engine crawlers rely on HTML tags to inform what's what, your site may rank better in search engine queries as well! This is a massive boon to your site's SEO score.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":1} -->
<h1 id="aria">Understand <code>aria-</code> properties</h1>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>In our previous example, we used an HTML attribute <a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-label_attribute"><code>aria-label</code></a> on our <code>ul</code>. <a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA">ARIA is collection of HTML attributes that allow you to enhance the accessibility in applications</a>. That said, <em><strong>it is highly encouraged to use the suggested HTML tags instead of <code>aria</code> attributes whenever possible</strong></em>. Think of <code>aria</code> as a complex low level API that can enhance your experience when done properly, but drastically harm user experience when improperly utilized.</p>
<!-- /wp:paragraph -->

<!-- wp:quote -->
<blockquote class="wp-block-quote"><p>No ARIA is better than Bad ARIA <a href="https://www.w3.org/TR/wai-aria-practices-1.1/#no_aria_better_bad_aria">WCAG WAI-ARIA Authoring Practices</a></p></blockquote>
<!-- /wp:quote -->

<!-- wp:paragraph -->
<p>A super small small subsection of <code>aria-</code> attributes includes:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-labelledby_attribute"><code>aria-labelledby</code></a> — Associate the element with another element's text as the label</li><li><code>aria-expanded</code> — A Boolean value meant to communicate when a dropdown is expanded</li><li><code>aria-valuemin</code> — The minimum allowed value in a numerical input</li><li><code>aria-valuemax</code> — The maximum allowed value of a numerical input</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>Additional to <code>aria</code> props, <a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques#roles">the <code>role</code> property</a> allows to tell the browser what an element's intended purpose is, thus changing it's behavior with accessible tech. Again, this is a highly advanced (and often incorrectly deployed) API for complex apps. To learn more, <a href="https://developer.mozilla.org/en-US/docs/Learn/Accessibility/WAI-ARIA_basics">read through Mozilla's ARIA basics article.</a></p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":1} -->
<h1 id="css">Classy CSS</h1>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>While HTML relays a significant amount of information to assistive technologies like screen readers, it's not the only thing used to inform those tools. Certain CSS rules can change the functionality as well. After all, screen readers (and other tools) don't look through the source code of a website. Instead, they're looking at <a href="https://developers.google.com/web/fundamentals/accessibility/semantics-builtin/the-accessibility-tree">the accessibility tree</a>: a modified version of the DOM. The accessibility tree and the DOM are both constructed by the browser from the website's source code.</p>
<!-- /wp:paragraph -->

<!-- wp:quote -->
<blockquote class="wp-block-quote"><p>Want to learn more about the DOM, how the browser constructs it, and what it's used for internally? <a href="https://unicorn-utterances.com/posts/understanding-the-dom/">This article helps explain this in detail</a>.</p></blockquote>
<!-- /wp:quote -->

<!-- wp:paragraph -->
<p>Because the DOM is influenced by CSS, it impacts the accessibility tree as well. For example, <code>display: none</code> removes the element from the <a href="https://benmyers.dev/blog/accessibility-tree/">accessibility tree</a> and from the browsers visual output. This means that screen readers won't read the contents of an element with that rule applied. However, <code>visibility: hidden</code> or <code>width: 0px</code> will hide an element visually, but will still be read by screen readers.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>For this reason, there's a frequently used CSS class used to hide elements visually but not from screen readers:</p>
<!-- /wp:paragraph -->

<!-- wp:code {"language":"css"} -->
<pre class="wp-block-code"><code>.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>There are many ways which CSS can influence assistive technologies. <a href="https://benmyers.dev/blog/css-can-influence-screenreaders/">Ben Myers covers this more in his blog post</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":1} -->
<h1 id="contrast">Contrast is Cool</h1>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>While screen readers are imperative to frontend accessibility testing, a site's visuals can help provide a good experience for many users. While a certain color palette may be aesthetically pleasing, it may be difficult to read for a colorblind user. Colorblind users aren't the only ones impacted, however.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>While there are various reasons a user might not be able to see weakly contrasted color, everyone is different. See if you can distinguish the text from the background in the displayed image with poor contrast:</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1841,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://coderpad.io/wp-content/uploads/2021/06/color_fail-1024x340.png" alt="Dark gray text on a black background, failing AA accessibility guidelines" class="wp-image-1841"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Now, compare that to highly contrasting colors:</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1843,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://coderpad.io/wp-content/uploads/2021/06/color_pass-1024x350.png" alt="White text on a black background, passing AAA accessibility guidelines" class="wp-image-1843"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>The contents are not only easier to distinguish from the background, but it's made easier to focus on as a result of the increased contrast.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>This said, not all contrasts are the same. Per <a href="#wcag">WCAG guidelines</a>, you may have a different ratio of contrast for different compliance levels. These contrast ratios depend on both font size as well as compliance level.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1844,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://coderpad.io/wp-content/uploads/2021/06/pass_aa_large-1024x351.png" alt="Light grey text passing AA for large text, but not small text" class="wp-image-1844"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>In this example you can see that the text passes the WCAG AA requirements for large text, but fails the same requirements for small text.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":1} -->
<h1 id="font-resize">Fantastic Fonts</h1>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>One of the most widely used accessibility features is font scaling. While many browsers default to a font size of <code>16px</code>, the user is actually able to change settings on their device to configure websites to use a larger font size.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Many phones using iOS and Android allow users to change the font size on their mobile devices. This feature is so commonplace that it often prompts users to change this setting when the phone is being set up.​</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1846,"width":512,"height":354,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large is-resized"><img src="https://coderpad.io/wp-content/uploads/2021/06/ios_text_size-1024x707.png" alt="" class="wp-image-1846" width="512" height="354"/><figcaption>iOS font size settings screen</figcaption></figure>
<!-- /wp:image -->

<!-- wp:image {"id":1847,"width":512,"height":366,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large is-resized"><img src="https://coderpad.io/wp-content/uploads/2021/06/android_text_size-1024x732.png" alt="" class="wp-image-1847" width="512" height="366"/><figcaption>Android font size settings screen</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>​</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Not only do you have these settings on mobile devices, but they're available on desktop as well.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Using Chrome, go to <a href="chrome://settings/?search=font+size">your settings page</a>, and you should be able to set your font size.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1848,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://coderpad.io/wp-content/uploads/2021/06/chrome_font_size-1024x219.png" alt="Font settings in Chrome" class="wp-image-1848"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>You can do the same in Firefox in <a href="about:preferences#general">your preferences</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1849,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://coderpad.io/wp-content/uploads/2021/06/firefox_font_size-1024x258.png" alt="Font settings in Firefox" class="wp-image-1849"/></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2 id="font-rem">Implementation</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>While browsers have the ability to set the font size, if you're using <code>px</code>, <code>vw</code>, <code>vh</code>, or other unit values for your fonts, the browser will not update these font sizes for you. In order to have your application rescale the font size to match the browser settings, you'll need to use the <code>rem</code> unit.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>You can think of <code>rem</code> as a multiplier to apply to the default font size. When the browser's font size is set to <code>16px</code>:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><code>1rem</code> will be <code>16px</code> (1 * 16px)</li><li><code>1.5rem</code> will be <code>24px</code> (1.5 * 16px)</li><li><code>3rem</code> will be <code>48px</code> (3 * 16px)</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>Likewise, when the browser's font size is set to <code>20px</code>:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><code>1rem</code> will be <code>20px</code> (1 * 20px)</li><li><code>1.5rem</code> will be <code>30px</code> (1.5 * 20px)</li><li><code>3rem</code> will be <code>60px</code> (3 * 20px)</li></ul>
<!-- /wp:list -->

<!-- wp:quote -->
<blockquote class="wp-block-quote"><p>Something to keep in mind is that <code>rem</code> is a <em>relative</em> font size. It's relative to the root element's font size. <em>This means that you cannot set a default <code>px</code> value font size in CSS to the <code>&lt;html&gt;</code> tag or to the <code>:root</code> selector, as it will disable font scaling, even if the rest of your page is using <code>rem</code> values.</em></p></blockquote>
<!-- /wp:quote -->

<!-- wp:paragraph -->
<p>It's highly encouraged to keep body text size standardized around the <code>1rem</code> value. While this may seem like a frustrating limitation at first, see it from the user's perspective. Font sizes can, of course, be larger than this for things like headers or callouts, but the primary content of your site should default to this sizing.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Say site "A" sets their font size to <code>1rem</code>, and site "B" sets their font size to <code>0.8rem</code>. When the user switches from "A" to "B", the font size drastically decreases, requiring the user to change their font size. Then, when they switch back to site "A", they're left with too large of font size. By respecting the user's setting of font size, you're ensuring that their experience jumping from site to site is more consistent and a nicer experience.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Want to learn more about <code>rem</code> and font sizing? <a href="https://www.24a11y.com/2019/pixels-vs-relative-units-in-css-why-its-still-a-big-deal/">Take a look at this in-depth blog post that covers even more</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":1} -->
<h1 id="keyboard">Keyboard is King</h1>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Just as developers have preferences with keyboard or mouse, so too do your end-users. Some people may only be able to utilize the keyboard to navigate the digital world. Not only is keyboard navigation critical for accessibility, but it enables power users of your application to be more efficient as well.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>While you may immediately think of "keyboard shortcuts" to trigger different applications, it's often easy to forget about smaller interactions as well.</p>
<!-- /wp:paragraph -->

<!-- wp:quote -->
<blockquote class="wp-block-quote"><p>This isn't to say that keyboard shortcuts aren't helpful - they can serve as shorthand for operations that might otherwise take considerable more effort using only the keyboard. Do consider implementing them in your app when they make sense.</p></blockquote>
<!-- /wp:quote -->

<!-- wp:paragraph -->
<p>Consider a site with a large number of navigation links like <a href="https://www.nytimes.com/">The New York Times</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1851,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://coderpad.io/wp-content/uploads/2021/06/nyt_initial-1024x486.png" alt="The initial homepage of New York Times" class="wp-image-1851"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Their site has 30+ individual items in their header that you'd need to tab through in order to get to the main portion of the website. Safe to say that most users of the site are likely to want to access that main content quickly. Additionally, users that rely on a screen reader that aren't familiar with the site's layout wouldn't know when to stop tabbing without slogging through every item in the header.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>As such, many sites (including New York Times) include a "Skip to Content" button that doesn't become visible until you've tabbed into it. Unless you were navigating the site by keyboard, you wouldn't know it was there.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1852,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="https://coderpad.io/wp-content/uploads/2021/06/nyt_skip-1024x486.png" alt="A &quot;skip to content&quot; button shown on the New York Times' site" class="wp-image-1852"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>This is far from the only considerations that should be made when considering a site's keyboard navigability, but is a prime example of a solution to a problem that might not be immediately obvious to users that primarily use the mouse.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="focus-indicator">Focus Indicators</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Something to keep in mind is that not all keyboard users use screen readers. Because of this, it's important to have an outline around the element you're currently focused on. Without this outline, how would a sighted person know where they are on the page?</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Imagine trying to use your mouse without being able to see your cursor or hover effects on elements — it would be nearly impossible to know what you were doing!</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Luckily, the browser provides a default outline out-of-the-box. That said, some developers unfamiliar with accessibility requirements may disable the outline, as they "don't like the look of the outline when using a mouse" or "think the outline is too obtrusive visually". They often do this by adding an <code>outline: none</code> rule to the element, which breaks the behavior of the browser.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Instead, it's suggested to either:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>Style the outline to be more consistent with your project's visuals (similarly to how The New York times made their outline styling black to match their site)</li><li>Style the element in some other way to indicate focus (avoid only using colors to differentiate, as colorblind users may not be able to distinguish the differences)</li><li>Use JavaScript to disable the behavior when mouse-events are detected (and re-enable if keyboard events are detected)</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>To learn more about the focus indicator and how to work alongside it, <a href="https://www.a11yproject.com/posts/2013-01-25-never-remove-css-outlines/">check out this blog post from The A11Y Project</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":1} -->
<h1 id="no-automation">Humans Can’t Be Automated</h1>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The perception for some is that accessibility is something that can be 1:1 adapted from an existing design. This is often untrue. You may want to add a "Skip to contents" button that only shows up with tabbing for some sites, while the visual order and tab order might need to be flipped for a better experience for screen-reader users. Remember, accessibility is a form of user experience that has to be crafted by hand. Each decision has nuance to it, and there are rarely objectives of which experience is better than others. Because of this, many companies will have dedicated accessibility specialists alongside their design and engineering teams.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>You also need to make sure to <a href="#testing">test your application</a> as you would any other part of your app. Automation is helpful here, but humans are still critical. We'll touch on this more in a future section.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If anyone is ever advertising to you that your inaccessible project can be made accessible (or prevent lawsuits) without any changes to your codebase, they're either lying to you or don't understand accessibility.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="eslint">Assistance is Amicable</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>While full automation will never be possible for improving a project's accessibility, not everyone proposing assistance in the process is trying to sell snake oil.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>For example, <a href="https://github.com/dequelabs/axe-core">Deque's open-source Axe project</a> can help identify issues such as common HTML semantic errors, contrast problems, and more. There are even libraries that help integrate Axe into your project's linters, such as one for React called <a href="https://github.com/jsx-eslint/eslint-plugin-jsx-a11y"><code>eslint-plugin-jsx-a11y</code></a>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>However, keep in mind that these tools are not infallible and are meant to supplement accessibility experts working with your engineering team, not replace them.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":1} -->
<h1 id="testing">Test, Test, Test Again</h1>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Testing is a critical component of any application release. Whether using automated testing solutions or QA teams, they help ensure that your users are getting the best experience possible without regressions in an application's behavior.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>As a developer working on the frontend, you should be regularly using an assistive technology like a screen reader to analyze your site and navigating your application <a href="#keyboard">with only your keyboard</a>. This will help enforce the feedback loop between building the functionality and getting it shipped to users. Make it part of your code review process — have other members of your team test with a screen reader as they would visually analyze new features.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>You're also able to include automated tests that will help with accessibility regressions. Either using <a href="https://kentcdodds.com/blog/write-tests">integration tests</a> or end-to-end tests, you can use real-world behavior such as "search for an element with this label" or "tab over to this button" to ensure your application is functioning as intended.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>As mentioned in <a href="#no-automation">a previous section</a>, the process to make your app accessible cannot be fully automated. This extends to testing as well. While real-world automated tests are fine and well, you need someone to experience the application on a broader scale to make sure the experience is as fluid as it can be. While a specific component might be accessible by default, perhaps in specific usages, it falls flat. <a href="https://www.w3.org/WAI/planning/statements/">Displaying an accessibility statement</a> while transforming your users' reported problems into bug tickets and performing user testing with disabled users are great ways to close the loop with the real people affected.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":1} -->
<h1 id="features">Fantastic Features</h1>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>While there is plenty you can do to make existing functionality accessibility friendly, it's often forgotten that a strongly accessible app may opt to add specific functionality for its users with disabilities.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Some great examples of things like this are sites with lots of user-generated content. For example, Twitter allows its users to <a href="https://help.twitter.com/en/using-twitter/picture-descriptions">add alternative (alt) text to their uploaded images and GIFs</a>. Likewise, YouTube has the ability to <a href="https://support.google.com/youtube/answer/2734796?hl=en">add subtitles and captions</a> to uploaded videos on their platform.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Oftentimes, you'll find that these features benefit everyone, not just assistive technology users. You may want to watch a video in a crowded area; with closed captions, that's a much easier sell than trying to hear over others and interrupting everyone around you.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":1} -->
<h1 id="further-reading">Radical Research</h1>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>While we've done our best to have this article act as a starting point for accessibility, there's always more to cover. Let's talk about some of the ways you can continue learning more.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Terminology</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>During your journey to learn more, you may run into terms that you're not familiar with. Let's take a look at some of the more predominant ones. We'll start this discussion of terminology with a common question:</p>
<!-- /wp:paragraph -->

<!-- wp:quote -->
<blockquote class="wp-block-quote"><p>What's "A11Y"?</p></blockquote>
<!-- /wp:quote -->

<!-- wp:paragraph -->
<p>A11Y is <a href="https://www.a11yproject.com/posts/2017-08-26-a11y-and-other-numeronyms/">a nymeronym</a> which stands for "accessibility". It's used as shorthand for the word in conversations about the subject.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Some other terms that might helpful are:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>"UI" — "User interface". The visual styling of an app</li><li>"UX" — "User experience". The interaction the user has with the app that defines their experience. This extends to assistive technology</li><li><a href="#wcag">"WCAG"</a> — "W3C Accessibility Guidelines", the standard guidelines for applications' accessibility support</li><li>"W3C" — "World Wide Web Consortium", the organization that publishes WCAG</li><li>"ADA" — "Americans with Disabilities Act", regulations in the US for businesses and governments which prohibits discrimination based on disability</li><li>"Alternative text"/"Alt text" — Short text used to describe images and other non-text assets</li></ul>
<!-- /wp:list -->

<!-- wp:heading -->
<h2>Tools</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>People in need of a screen reader have multiple options at their disposal. Just a few of them include:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><a href="https://www.freedomscientific.com/products/software/jaws/">JAWS</a> — An incredibly popular paid Windows screen reader</li><li><a href="https://www.nvaccess.org/">NVDA</a> — A Windows screen reader</li><li><a href="https://www.apple.com/accessibility/vision/">VoiceOver</a> — The screen reader for iOS and macOS</li><li><a href="https://support.google.com/accessibility/android/answer/6283677?hl=en">TalkBack</a> — The screen reader for Android</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>It's important to keep in mind that just as browsers may have differing behaviors for CSS or JavaScript, so too may these screen readers. Be sure to test with more than one of them as you would with different browsers.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Screen readers aren't the only accessible tech, however. A small example of them might be:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><a href="https://www.afb.org/node/16207/refreshable-braille-displays">Braille Displays</a></li><li><a href="https://axesslab.com/switches/">Switches</a></li><li><a href="https://en.wikipedia.org/wiki/Eye_tracking#Assistive_technology">Eye tracking</a></li></ul>
<!-- /wp:list -->

<!-- wp:heading -->
<h2>Additional Resources</h2>
<!-- /wp:heading -->

<!-- wp:list -->
<ul><li><a href="https://web.dev/a11y-tips-for-web-dev/">Google's accessibility tips for web developers</a></li><li><a href="https://developer.apple.com/design/human-interface-guidelines/accessibility/overview/introduction/">Apple's accessibility guidelines</a></li><li><a href="https://webaim.org/">WebAIM's website with a plethora of resources</a></li><li><a href="https://www.a11yproject.com/">The A11Y Project</a></li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>Additionally, there are a few sites that contain extensive lists of additional resources:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><a href="https://www.a11yproject.com/resources/">A11Y project's list of external resources</a></li><li><a href="https://a11y.me/">A11Y &amp; Me resource list</a></li></ul>
<!-- /wp:list -->

<!-- wp:heading {"level":1} -->
<h1 id="conclusion">Conclusion</h1>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>We hope you've enjoyed learning from our accolade-worthy alliterative headlines.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>There are so many things that we wanted to include in this article but couldn't. Like most parts of engineering, the field of accessible design and the nuances within can be incredibly complex in fringe scenarios. Getting accessibility in a great place for your users takes active effort - just like any other part of building your app. Because of this, we encourage you to do <a href="#further-reading">further research</a> on the topic. Don't be afraid to ask questions of community members, either! Many in the community are incredibly helpful and friendly.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Speaking of community, we'd love to hear your thoughts on this article. Did you learn something from it? Have questions about something accessibility-related? Think we missed something? <a href="https://bit.ly/coderpad-slack">Join our Slack community</a> and chat with us or <a href="https://twitter.com/coderpad">send us a Tweet</a>!</p>
<!-- /wp:paragraph -->