Your fortnightly frequent11y newsletter, brought to you by @ChrisBAshton:
We begin with a Smashing Magazine special! It’s a great publication – which I’ve written for a few times – and I’ve had some of their a11y articles sitting in my bookmarks for a while. These articles are long and full of useful info, so it’s sure to be a bumper week. Let’s dive in!
Making Sense Of WAI-ARIA: A Comprehensive Guide
An article by Kate Kalcevich, Head of Accessibility Innovation at Fable. She recaps how HTML is parsed into two structures: the DOM and the Accessibility Tree. Assistive technologies access the accessibility tree nodes to understand the element role, state and name. Native HTML elements such as <input>
populate both structures automatically, but custom components made up of <div>
s and <span>
s need extra markup to fill the accessibility tree properly. This markup is called ARIA (Accessible Rich Internet Applications).
ARIA gives extra information about an element, but doesn’t give extra behaviour. For example, adding role="button"
to a div
won’t make it respond when you press the Enter
key, but it does tell the accessibility tree what it’s claiming to be. The ARIA Authoring Practices Guide includes a list of what interactivity should be added to various components such as accordions, buttons, carousels, and the MDN web docs has a complete list of available roles.
Kate cherry-picks some key ARIA states and properties:
aria-checked
("true"
or"false"
) to indicate whether checkboxes and radio buttons are currently checkedaria-current
("true"
or"false"
) to indicate the current page within breadcrumbs or paginationaria-describedby
– used with the id of an element containing extra information for a form field beyond just its label, e.g. examples of the required format for a fieldaria-expanded
("true"
or"false"
) to indicate if pressing a button will show more content (e.g. accordion)aria-hidden
("true"
or"false"
) to hide something that is visible, but you don’t want assistive technology users to know about it, e.g. a card component with image and text linking to the same place, but structured as two links; usearia-hidden="true"
on one of the links.aria-required
("true"
or"false"
) to indicate if a form element has to be filled out before the form can be submitted
And Kate rattles off some of the most common ARIA-related mistakes:
- Using an
aria-labelledby
attribute with an ID that doesn’t exist - Adding roles unnecessary (
<button role="button">
) - Using child roles without parent roles (e.g.
<li role="option">
without a direct parent withrole="listbox"
) - Using
role="menu"
for navigation; it’s intended for things like custom menus on right click, not for general site navigation, which is more of a table of contents than a menu. For the latter, use<nav aria-label="Main menu">
. Read Heydon Pickering’s Building Accessible Menu Systems for more.
Finally, there’s a section on focus management, how to validate ARIA, and resources for frameworks and component libraries.
Accessible Front-End Patterns For Responsive Tables (Part 1)
Adrian Bece writes two in-depth articles about implementing responsive tables.
He shares Adrian Roselli’s JavaScript snippet that applies the correct ARIA roles to table elements, which are to ensure that browsers continue to keep good table semantics even when certain CSS styles are applied. The snippet is from 2018, but an update in December 2022 suggests it is still needed for Safari. Note that the JS itself isn’t needed, but the resulting markup, which you could add to your HTML manually or in a preprocessor.
Tables should have a <caption>
element as the first child, with a nested heading describing the contents of the table. If it can’t be the first child – e.g. because you’ve added a wrapper element to make the table scrollable – you’ll need to include the table in a <figure>
element, use a <figcaption>
for the title, and apply a aria-labelledby
to the table’s wrapper.
Small / simple tables can be made neatly responsive with table { width: fit-content }
, to remove any unnecessary space when viewing on larger screens. For tables with lots of columns, it becomes necessary to horizontally scroll, by applying an overflow: auto
to the wrapper element, alongside a tabindex="0"
to make it usable for keyboard users.
Some OS’s hide scrollbars by default (I’m looking at you, macOS!), so you may want to consider adding a shadow gradient to indicate the table is scrollable. With background-attachment: local, local, scroll, scroll;
, you can subtly hide and show the shadow on either ‘edge’ of the table depending on the direction you scroll. Another visual cue to let the user know a table is scrollable is to force a crop of the last visible column. You may want to consider making the table headers sticky, to keep them in view as you scroll.
Adrian then discusses the stacking approach; useful for tables where the data isn’t supposed to be ‘compared’, e.g. a table of people and their contact information. In the demo, each ‘row’ gets pulled into its own ‘block’ on smaller screens. But this can make pages very tall on mobile. An alternative is the accordion pattern, where you may choose to only show the primary data column (e.g. user’s name) on smaller screens, with a button to expand and reveal the other columns as needed (see demo). Another space-saving option is to give users the ability to show/hide columns.
In Part 2, Adrian looks at patterns for much larger tables, including how to improve their rendering performance by either paginating the results, virtualising the rendering (i.e. keeping the table in memory but only rendering the number of DOM nodes you need in view), or exploring the CSS contain: strict
property. Adrian also touches on JavaScript libraries for enhancing tables, and some other special use cases such as rendering calendars.
When CSS Isn’t Enough: JavaScript Requirements For Accessible Components
Stephanie Eckles shares those scenarios where you need a sprinkling of JavaScript to make components accessible. The TLDR is that these include “tooltips, modals, tabs, carousels, and dropdown menus”. Components marketed as “CSS-only”, that use methods like the “checkbox hack“, often do more harm than good.
As a quick sense check, ask yourself the following:
- Does the feature include showing and hiding of content? If so, you need JS to at minimum “toggle aria and enable closing on
Esc
“ - Is the natural focus order the most ideal? “If the natural order loses the relationship between a trigger and the element it triggered, or a keyboard user can’t even access the content via natural tab order, then you need JS to assist in focus management”
- Does the effect rely on hover and/or focus? You may need JS to make an alternative solution “for touch screen users and those using desktop zoom of 200%+ or magnification software”
Tooltips should be used as a last resort. Ask yourself why you’re adding this text to the UI, and where else it could go. But if you do use one, make sure it’s dismissable without moving hover or focus, that its contents can be hovered without it disappearing, and that it doesn’t disappear based on a timeout.
Modals, as we’ve covered in previous frequent11y issues, would ideally be implemented with a HTML native <dialog>
element, but it isn’t currently accessible. Custom solutions need JS because it should be dismissable with the Esc
key, and the keyboard focus should be trapped inside. As to what to focus on when opening the modal, Stephanie’s presented a decision tree.
Tabs need to toggle aria-selected
to true
for the current tab, create a roving tabindex to “distinguish tab selection from focus”, and move focus by responding to arrow key events, all of which require JavaScript. NB: a roving tabindex is a way of programmatically controlling the focus order of elements, e.g. by setting the selected tab to tabindex="0"
and all the others to -1
.
Dropdown menus need JS, even though we now have CSS’s :focus-within
property, because we still need to toggle aria-expanded
, be able to close the open menu button with Esc
and implement arrow keys for navigating between menu items.
Carousels are notoriously considered a bad design pattern, but if you’re going to build one, you’ll need JS to provide paginated and prev/next controls, as well as auto play.
“I Used The Web For A Day…” series
I said earlier that I’d written some articles for Smashing Magazine in the past. As this issue is a Smashing Mag special, I thought I’d share those articles with you now! Mine was a short series on using the web for a day, but with a limitation: to highlight barriers to accessibility and provide tips on how to build a better web.
You can read the articles below:
- I Used The Web For A Day With JavaScript Turned Off
- I Used The Web For A Day With Just A Keyboard
- I Used The Web For A Day Using A Screen Reader
- I Used The Web For A Day On Internet Explorer 8
- I Used The Web For A Day On A 50 MB Budget
Now, onto non-Smashing-Magazine things…
Twitter is getting rid of its free API tier. That’s a nightmare for accessibility activists.
Twitter has announced that, starting February 9, they will no longer support free access to the Twitter API (both v1.1 and v2). This move has not been popular, including with myself – basic things like the automatic tweeting of my dai11y article will probably just stop working. Only time will tell!
This Mashable article details some of the accessibility bots that may no longer be viable. There are bots that highlight a lack of alt text in newsroom and government tweets, which I covered in dai11y 21/10/2022. There’s also @A11yAwareness, a bot with over 17k followers, which shares tips and articles about accessibility. The owner of the bot will now have to sift through findings and manually schedule all of the account’s tweets to keep it running.
Then there are the various ‘utility’ bots that serve as accessibility tools for users with various disabilities. These include the Thread Reader app (or ‘unroll’), which makes it easier for users to read long Twitter threads. Or an Alt Text Reader app that visually surfaces any manually added alt text, which can otherwise be hard to find. Then there are third party clients like Tweetbot and Twitterific, which no longer work – some of these clients were aimed at providing better accessibility than native Twitter.
This comes on top of Twitter’s accessibility team being let go last November, resulting in no updates to Twitter’s accessibility page since October.
Chris’s look at ChatGPT
I’ve had a few ChatGPT related accessibility articles in my inbox of late – I’ve read them and summarised them so you don’t have to!
In “How ChatGPT can help your code be accessible“, Ashley Smith describes how you can use ChatGPT to give you some markup as a base to build upon. For example, you can ask it to write the code for a green “Read More” button, in React, that is “completely 508 compliant“, and it will give you a snippet of code.
I strongly caution against this. What ChatGPT generates might make rough sense to you, the reader, it has no proper understanding of what it’s talking about. In other words, it’s a bull**** generator. For example, in the code example ChatGPT returned for the above request, we have a completely unnecessary aria-label
on our button. It is dangerous to just copy and paste ChatGPT’s output and assume everything is fine: a code snippet isn’t necessarily accessible just because you asked ChatGPT to make it so.
Scott O’Hara covers exactly this example in “Setting expectations for asking ChatGPT web accessibility questions“. He expands on why an aria-label
on a button can actually be actively harmful, such as if you’re using a ‘translation widget’ to translate a page into another language. These widgets often neglect the values of aria-label
attributes, concentrating only on visible text. There are other parts of the answer ChatGPT gave to Scott, which he picks apart (such as the unnecessary recommendation to give the button a tabindex
and to use JavaScript to listen for ‘Enter’ or ‘Spacebar’ key presses).
Finally, in “Will ChatGPT threaten the future of the digital accessibility field?“, Denis Boudreau actually has a Q&A style interview with ChatGPT on where it sees itself (insofar as it can) in the realm of a11y. It’s actually given some very self-aware answers that I wouldn’t argue with! I’ve pulled out some snippets below:
As a large language model, my primary purpose is to assist users in generating human-like text based on the input provided to me. I do not have the ability to impact the future of the field of digital accessibility or any other field.
The future of the field of digital accessibility will be shaped by a variety of factors, including advances in technology, changes in laws and regulations, and shifts in societal attitudes towards accessibility. It is important for professionals in this field to stay current with developments in these areas and to continue to work towards creating more inclusive and accessible digital products and services. However, the success or failure of a particular natural language processing model is unlikely to be a major determining factor.
Digital accessibility is a multifaceted field that encompasses a wide range of technologies, design principles, and best practices. While natural language processing models can certainly play a role in making digital products more accessible to people with disabilities, they are just one part of the larger ecosystem of tools and strategies used to achieve this goal.
It is important to recognize that [ChatGPT is] not a substitute for expert knowledge and understanding in the field of accessibility. Natural language processing models are limited by the data they are trained on and the algorithms they use, and they may not always produce accurate or reliable information.
Natural language processing models are trained on large data sets, but the quality and relevance of that data can vary. Some models… may be trained on data sets that are more limited in scope or that contain biases or errors. As with any source of information, it is important for aspiring accessibility professionals to critically evaluate the quality and accuracy of the information they are using, regardless of whether it comes from a natural language processing model or any other source.
The article concludes with some suggestions for how ChatGPT can best be used as a tool in the field of accessibility. These suggestions, again, are provided by ChatGPT, but look very sensible!
Progressive enhancement poem in the style of Shakespeare
In more a11y ChatGPT news, my colleague Derren Wilson asked ChatGPT to “explain progressive enhancement in the style of shakespeare”, and I’m absolutely gobsmacked at the results. Enjoy.
Hark! What light through yonder window breaks?
It is the concept of Progressive Enhancement,
That doth illuminate the web with its grace.Forsooth, Progressive Enhancement is a noble goal,
To build a website with layers that unfold,
To ensure that all may access its content whole,
Be they on a phone or a screen vast and bold.At first, the website is built with simple means,
With plain HTML and CSS, so it seems,
But as the layers add on, like a rising sun,
The website grows in beauty and function.With each layer, new features are revealed,
And yet, the website’s core remains unpeeled,
Accessible to all, no matter their device,
No user left behind, no matter the price.Thus, Progressive Enhancement is a shining star,
A beacon of hope, in a web world that’s marred,
A way to build websites that all may share,
And make the web a place that’s just and fair.
Meet the first-ever accessibility engineer at The Washington Post
The Washington Post hired Holden Foreman in January. Holden is keen to stress that whilst he is the first person at the newspaper with the ‘Accessibility Engineer’ title, accessibility is not a new concept there and the lack of formal roles at smaller news organisations does not mean that those places don’t care about accessibility.
Holden started working at the Post in 2020. Interestingly, he was key in pushing for the creation of an Accessibility Engineer role:
I started an informal working group at the company with biweekly meetings for skill shares, news, internal updates, shoutouts and other discussions related to accessibility. With the help of Julie Bacon Arsenault, one of the Post’s engineering directors, I delivered a pitch last year for an accessibility engineer job title. Arturo Silva, an engineering manager who oversees the Washington Post Design System among other things, was willing to make a home for the role on his team.
He sees his role as exploring new opportunities in research and feature development, as well as educating others at the company and being a resource for support. He also hopes to create a stronger dialogue with users, to learn how people actually use the Post’s tools.
Holden adds that accessibility isn’t just about coding, or even about disability:
It’s essential to think about accessibility not just in the context of disability but also in the context of other inequities affecting news coverage and access to news. For instance, writing in plain language for users with cognitive disabilities can also benefit users with lower reading literacy.
[The Post published a plain language version of Foreman’s introductory blog post]
The interview more or less concludes with Holden’s thoughts on the role:
It’s definitely stressful to be the first in this new role. I feel deep down like I need to justify its creation with every step that I take. My managers and colleagues have been fully supportive, and it is thanks to them that the role exists, so I would say that the pressure feels self-enforced. Thankfully, there is a lot of collaboration in the accessibility world, and I have already been in contact with some folks from outside of The Post regarding how we can support each other.
Did you know that you can subscribe to dai11y, week11y, fortnight11y or month11y updates! Every newsletter gets the same content; it is your choice to have short, regular emails or longer, less frequent ones. Curated with ♥ by developer @ChrisBAshton.