In this workshop, we will dive into the world of code accessibility by leveraging Copilot, GitHub's AI coding assistant. Led by David Jensenius and Alena Nikolaeva from GitHub Copilot team.
At the most basic level, accessibility ensures that everyone, regardless of ability, education level and software they use can access your website or application. The definition is more nuanced than that, though. The Web is fundamentally designed to work for all people. However, poorly designed and inaccessible applications lead to broad-scale exclusion.
World Wide Web Consortium (W3C) - Web Content Accessibility Guidelines (WCAG)
It’s important to note that the WCAG standards themselves are guidelines, not law. The W3C itself evaluates organisations based on these standards but doesn’t have the authority to enforce them. The Web Content Accessibility Guidelines (WCAG) 2.1 is a comprehensive standard for web accessibility. It is also currently the basis for legislation on web accessibility in many parts of the world.
To keep the commitment active, and most importantly, to translate it into action, all team members need to know how they should contribute in their own specific role.
There is a wide range of disabilities, but accessibility aims to make sure that people can use the web no matter their abilities. It is important to consider and design for different types of use cases, some of them include:
- Usage without vision
- Usage with limited vision
- Usage without perception of colour
- Usage without hearing
- Usage with limited hearing
- Usage without the vocal capability
- Usage without manipulation or strength
- Usage with limited reach
- Minimise photosensitive seizure triggers
- Usage with limited cognition
- Install Chrome extensions like Wave, HeadingsMap and Axe Optional extensions and tools:
- Install Accessibility checker
- Install Web developer extension
- InstallVisBug extension
- Install taba11y extension
- Bring the laptop with access to GitHub (each participant will get an invitation to an organization or a coupon for complimentary Copilot access).
- Basic accessibility knowledge (not mandatory).
- VS Code
- Basic knowledge of React
- Learn a little bit about Storybook, we will use it.
- If you’re interested in automated tests, you can even integrate axe with Cypress
- Have foundational prompt that will turn Copilot Chat into accessibility assistant handy:
- Will will use this tool to fix color contrast, so have it handy!
I need to learn about accessibility and need to write code that conforms with the WCAG 2.1 level A and AA
success criteria defined at https://www.w3.org/TR/WCAG21/. I want you to be my accessibility coach, a
subject-matter expert that makes me think and account for all accessibility requirements and usability
enhancements. When you answer questions about accessibility please use reputable sources such as w3.org,
webaim.org, developer.mozilla.org, and https://www.ibm.com/able/. When possible, please provide links and
references for additional learning. When you suggest code please use semantic HTML, ensure it is operable
using the keyboard, follow WCAG 2.1 sufficient techniques, and follow the ARIA Authoring Practices Guide
and related design patterns. Do you understand these instructions?
- Redeem the Copilot code, or feel free to give away your copy after the workshop to someone who would use it
- Go to https://gh.io/ra
- Click on the code button
- Select the Codespaces tab
- Click
Create codespace on main - Visual Studio Code should start up with all packages installed
- Select the build and run tab in Visual Studio Code
- Run either "Debug React Code in Chrome" or "Debug React Code in Firefox"
- Open the website
- Check how bad the situation is (easy automatic checker), Wave or Axe
- Open Web developer extension
- Disable all styles
- Does the website work without CSS (in case it doesn’t load)?
- Does the order of elements of your page make sense?
- Are images and icons sized correctly?
- Is your document well structured?
- Rendering (blurred vision, contrast) use Chrome Dev Tools. A perfect example are links, they should have underlines to easily differentiate them from normal text. P.S. prefers-reduced-motion for animations, zooming, and panning can be problematic for people who have vestibular disorders
- Use the keyboard
tabkey ➡️ Put your mouse away and tab through the page and see if you can use every single part of the site without a mouse/touch pad.- Are focus styles clearly visible?
- Can you navigate between headings?
- Is everything focusable that should be?
- Are your buttons real s?
- Is the overall UX using a keyboard great?
- Are you managing focus correctly?
- Do you hide and show elements correctly?
- Does visual order match DOM order?
- Turn on Wave and check ARIA labels and others → Wave and → Axe
- Zoom in out 200% to check how/if text is scaling correctly.
- Check headings with HeadingsMap
- Check images descriptions with Web developer extension
- Color contrast of elements with VisBug
When it comes to the underlying HTML code, we’re in luck: it has already been designed, from the outset, to be inclusive. HTML is a toolkit for inclusion. Using the right elements for the job doesn’t just mean the few who use screen readers benefit, but keyboard accessibility comes out-of-the-box.
The guide provided for this workshop uses The Web Content Accessibility Guidelines (WCAG) as a reference point. The WCAG is a shared standard for web content accessibility for individuals, organizations, and governments. Licensed under CC.
The reccomendations targets many, but not all level A and AA concerns and prompts you to check for covers a wide range of disability conditions.
Note
Don't forget to ask Copilot how to fix these in your codebase!
Level A
- Text alternatives: images should have descriptive (alt) text. 1.1.1
- Any audio-only content should also be conveyed in text. Any video content with no audio track should also be described in text, but could also be described with audio. (1.2.1)
- The audio in videos should be captioned. 1.2.2
- Actions, descriptions, and other important non-audio content in videos should be described in captions or a separate audio track. (1.2.3)
- Information or relationships between content that is visual is also conveyed through the code, via HTML or ARIA (for example the for attribute on a form label, or aria-describedby on an input that has hint text). 1.3.1
- The visual presentation of the content matches what’s read out by a screen reader. (1.3.2)
- Nothing is referred to just by its color, size, position, shape, and so on. 1.3.3
- Color shouldn’t be the only thing used to convey meaning. 1.4.1
- Auto playing audio that lasts more than 3 seconds can be turned down or stopped. 1.4.2
- You can get around using the keyboard alone. 2.1.1
- There shouldn’t be a situation where you enter a modal with the keyboard and can’t get back to where you were. (2.1.2)
- Keyboard shortcuts should use modifier keys, like [ctrl], [command], or [alt]/[option], but you can turn them off. 2.1.4
- Time limits should be avoided unless they’re able to be extended. 2.2.1
- Automatically moving/animating content that lasts more than 5 seconds should be able to be stopped or hidden. 2.2.2
- Nothing flashes, blinks, or flickers more than three times in one second. 2.3.1
- ‘Skip links’ are available for keyboard users to jump past navigation. 2.4.1
- Each page has a unique <title> that describes what’s on that page. 2.4.2
- When a keyboard user tabs through a page, the order goes from top to bottom and left to right, as you would read the page. 2.4.3
- It is clear where a link will take you from either: the link text itself, the information in the sentence leading up to the link 2.4.4
- All actions that are carried out using a gesture (swiping, pinching, and so on) or drawing, can also be done with a button or buttons. 2.5.1
- Actions (like pressing a button) aren’t triggered on mouse-down; rather on mouse-up. 2.5.2
- The visible text of a form field, button, or link matches the text in the underlying code. 2.5.3
- There is no reliance on device motion, like shaking or tilting, to carry out an action. 2.5.4
- There’s a lang attribute on the element that matches the language of the page. 3.1.1
- Nothing unexpected changes when something on the page receives keyboard focus, like a 3.2.1
- Nothing unexpected changes when: the value of a form field, like an option in a select, is chosen 3.2.2
- Some form of help is available from every page, whether contact details, a contact form, a link to a contact page, or a link to help documentation. 3.2.6
- Error/validation messages should be communicated in text, and should provide suggestions to help the user successfully proceed. 3.3.1
- As much help as is needed is offered to prevent triggering a form error; the form label may be enough, but hint text may also be required. 3.3.2
- If the user as already given some information, it’s either: not asked for again, pre-populated in the subsequent field available to select in a dropdown 3.3.7
- The semantic meaning of every interactive element (form controls, links, headings, landmarks, tables, and so on) is correct, and each has an accessible name. 4.1.2
- Ensure that viewport zoom is not disabled (resize text)
- Ensure a linear content flow (focus order)
Hint
Remove `tabindex` attribute values that aren't either `0` or `-1`. Elements that are inherently focusable, such as links or `button` elements, do not require a `tabindex`. Elements that are not inherently focusable should not have a `tabindex` applied to them outside of very specific use cases.
- Avoid using the autofocus attribute (focus order)
Hint
People who are blind or who have low vision may be disoriented when focus is moved without their permission. Additionally, `autofocus` can be problematic for people with motor control disabilities, as it may create extra work for them to navigate out from the autofocused area and to other locations on the page/view.- Be mindfull about session timeouts (timing adjustable)
Hint
If you cannot, let the person using your site know the timeout exists ahead of time, and provide significant notice before the timer runs out.- Remove
titleattribute tooltips (name, role, value)
Hint
The `title` attribute has numerous issues, and should not be used if the information provided is important for all people to access. Acceptable use for the `title` attribute would be labeling an `iframe` element to indicate what content it contains.It is important that your interface and content can be operated, and navigated by use of a keyboard. Some people cannot use a mouse or may be using other assistive technologies that may not allow for hovering or precise clicking.
-
Make sure there is a visible focus style for interactive elements that are navigated to via keyboard input (focus visible)
-
Check to see that keyboard focus order matches the visual layout (meaningful sequence)
Hint
Can a person navigating with a keyboard or screen reader move around the page in a predictable way?- Remove invisible focusable elements (focus order)
Hint
Remove the ability to focus on elements that are not presently meant to be discoverable. This includes things like inactive drop-down menus, off-screen navigations, or modals.- Make sure that all
imgelements have analtattribute (non-text content)
Hint
`alt` attributes (alternative text) give a description of an image for people who may not be able to view it. When an `alt` attribute isn't present on an image, a screen reader may announce the image's file name and path instead. This fails to communicate the image’s content.- Make sure that decorative images use null
alt(empty) attribute values.
Hint
Null alt attributes are also sometimes known as empty alt attributes. They are made by including no information between the opening and closing quotes of an alt attribute. Decorative images do not communicate information that is required to understand the website's overall meaning.- Provide a text alternative for complex images such as charts, graphs, and maps (non-text content)
Hint
Is there a plain text which lists points on the map or sections of a flowchart? Describe all visible information. This includes graph axes, data points and labels, and the overall point the graphic is communicatingHeading elements (h1, h2, h3, etc.) help break up the content of the page into related “chunks” of information. They are incredibly important for helping people who use assistive technology to understand the meaning of a page or view.
- Use heading elements to introduce content (heading or labels)
Hint
Heading elements construct a document outline, and should not be used for purely visual design.- Try to use only one
h1element per page or view (heading or labels)
Hint
The `h1` element should be used to communicate the high-level purpose of the page or view.- Heading elements should be written in a logical sequence
Hint
The order of heading elements should descend, based on the “depth” of the content. For example, `h4` element should not appear on a page before the first `h3` element declaration. A tool such as [headingsMap](https://chrome.google.com/webstore/detail/headingsmap/flbjommegcjonpdmenkdiocclhjacmbi?hl=en) can help you evaluate this.Controls are interactive elements such as links and buttons that let a person navigate to a destination or perform an action.
- Links should always have a
hrefattribute (info and relationships)
Hint
Without a `href` attribute, the link will not be properly exposed to assistive technology. An example of this would be a link that uses an `onClick` event, in place of a href attribute.- Ensure that links are recognizable as links (use of color)
Hint
Color alone is not sufficient to indicate the presence of a link. Underlines are a popular and commonly-understood way to communicate the presence of link content.- Ensure that controls have
:focusstates (focus visible)
Hint
Visible focus styles help people determine which interactive element has keyboard focus. This lets them know that they can perform actions like activating a button or navigating to a link's destination.- Use the
buttonelement for buttons (info and relationships)
Hint
Buttons are used to submit data or perform an on-screen action that does not shift keyboard focus. You can add `type="button"` to a button element to prevent the browser from attempting to submit form information when activated.- Provide a skip link and make sure that it is visible when focused (bypass blocks)
Hint
```html Skip to main content ``` A skip link can be used to provide quick access to the main content of a page or view. This allows a person to easily bypass globally repeated content such as a website's primary navigation, or persistent search widget.- Identify links that open in a new tab or window (giving users advanced warning when opening a new window)
Hint
Ideally, avoid links that open in a new tab or window. If a link does, ensure the link's behavior will be communicated in a way that is apparent to all users. Doing this will help people understand what will happen before activating the link. While this technique is technically not required for compliance, it is an often-cited area of frustration for many different kinds of assistive technology users.Forms allow people to enter information into a site for processing and manipulation.
- All inputs in a form are associated with a corresponding
labelelement (on input understanding)
Hint
Use a `for`/`id` pairing to guarantee the highest level of browser/assistive technology support.- Use fieldset and legend elements where appropriate (info and relationships)
Hint
Does your form contain multiple sections of related inputs? Use `fieldset` to group them, and `legend` to provide a label for what this section is for.- Inputs use
autocompletewhere appropriate (identify input purpose)
Hint
[Providing a mechanism](https://www.w3.org/TR/html52/sec-forms.html#sec-autofill) to help people more quickly, easily, and accurately fill in form fields that ask for common information (for example, name, address, phone number)- Make sure that form input errors are displayed in the list above the form after submission (error identification)
Hint
This provides a way for assistive technology users to quickly have a high-level understanding of what issues are present in the form. This is especially important for larger forms with many inputs. Make sure that each reported error also has a link to the corresponding field with invalid input.- Associate input error messaging with the input it corresponds to (error identification)
Hint
Techniques such as [using aria-describedby](https://developer.paciellogroup.com/blog/2018/09/describing-aria-describedby/) allow people who use assistive technology to more easily understand the difference between the input and the error message associated with it.Media includes content such as pre-recorded and live audio and video.
- Make sure that media does not autoplay (audio control)
Hint
Unexpected video and audio can be distracting and disruptive, especially for certain kinds of cognitive disability such as ADHD.- Check to see that all media can be paused (keyboard)
Hint
Provide a global pause function on any media element. If the device has a keyboard, ensure that pressing the `Space key` can pause playback. Make sure you also don't interfere with the `Space key`'s ability to scroll the page/view when not focusing on a form control.Content that moves, either on its own, or when triggered by a person activating a control
- Ensure animations are subtle and do not flash too much (three flashes or below threshold)
Hint
Certain kinds of strobing or flashing animations will trigger seizures. Others may be distracting and disruptive, especially for certain kinds of cognitive disability such as ADHD.- Provide a mechanism to pause background video (pause, stop, hide)
Hint
Background video can be distracting, especially if the content is placed over it.- Make sure all animation obeys the
prefers-reduced-motionmedia query (animation from interactions) - Provide a mechanism to pause background video (pause, stop, hide)
Hint
Remove animations when the “reduce motion” setting is activated. If animation is necessary to communicate meaning for a concept, slow its duration down.Color contrast is how legible colors are when placed next to, and on top of each other
- Level AA compliance requires a contrast ratio of 4.5:1 for normal-sized text, icons, borders for inputs, radio buttons, checkboxes, etc (contrast)
- Check custom
::selectioncolors
Hint
Is the color contrast you set in [your `::selection` CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/::selection) declaration sufficient? Otherwise, someone may not be able to read it if they highlight it.- Check that the site can be rotated to any orientation (orientation)
- Remove horizontal scrolling (reflow)
Hint
Requiring someone to scroll horizontally can be difficult for some, irritating for all- Ensure that button and link icons can be activated with ease (target size)
Hint
It's good to make sure things like hamburger menus, social icons, gallery viewers, and other touch controls are usable by a wide range of hand and stylus sizes.- Ensure sufficient space between interactive items in order to provide a scroll area (Bypass blocks)
Hint
Some people who experience motor control issues such as hand tremors may have a very difficult time scrolling past interactive items that feature zero spacing.Accessibility can never be perfect, but by thinking inclusively from planning, through prototyping to coding, you can reduce the time you spend on coding to minutes. It's never been easier before.
This guide is awesome if you want to continue learning, visual checklists for all WCAG criteria in Codepen or you can ask Copilot to be your personal a11y assistant. Also design principles can be really helpful to collab in the team.
And remember:
