A11Y 101: WAI-ARIA Roles

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
Search for a command to run...

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
No comments yet. Be the first to comment.
In this series I'll explore the basics of accessibility and you can join me on this learning trip.
In the previous article, we had a look at what the WAI-ARIA is and which global parts it comes with. I'll go a bit deeper into WAI-ARIA properties in this specific article. As a reminder, properties give extra meaning to an attribute, as to states th...
Most of you know me for my consistency, a golden arrow in my blog series. I've written 1000 articles in 1008 days! Almost an article a day, and my honeymoon was the only holiday I ever took. I'm super proud of this achievement; it has been a fantasti...

It's not the first time I'll be talking about community. I think it's an essential aspect of any successful tool. This shows in my previous explorations of Astro, Medusa, and now Vendure as well. All these products thrive in a super open, welcoming, ...

The cool part about Vendure is how easy it is to set up and how abstract each layer is. Basically, we get the following elements: External database Server Worker Admin UI Frontend While this is amazing, it also brings a bit of complexity when it co...

The previous article looked at customizing Vendure on a data and process level. In this article, we'll look at customizing emails, as they are often a big part of a webshop system. We'll be looking at two different layers of customization for customi...

Even though Vendure is a pretty significant project out of the box, in some cases, we might want to go in and modify some elements to work to our specific use case. In this article, I'll take a high-level look at some elements we can customize within...

In the previous article, we had a short introduction to WAI-ARIAs and what they are.
Today we'll dive a bit deeper into one of the elements: WAI-ARIA roles.
The specific roles can add semantic meaning to elements where HTML might miss this context. By doing so, we allow accessibility tools like a screen reader to understand our website structure.
Certain elements have these roles by default. For example, <nav> elements already have a navigation role.
And <input type="radio"> will be a radio role.
But non-semantic elements like div and span have no roles. In some cases, we might want to set these explicitly.
We can split these roles into six different categories.
These roles are used to add a structural description for a section of content. Most of these should have semantic alternatives nowadays.
However, there are still a few that have no specific semantic variant like: toolbar, tooltip, and feed.
Widget roles can be used to identify interactive patterns. With these, there are often also semantic equivalents that should be used.
The main difference between document structure and widgets is that those widget roles require JavaScript interaction; for the document ones, it's unnecessary.
Some examples: scrollbar, slider and tab.
Landmarks are used to identify the organization and structure of a webpage on a higher level.
It would be best if you used these sparingly as they can create a lot of noise for people to understand your structure.
Some examples are: form, main, and navigation.
Live regions are elements that include dynamic content that can change. For visual users, these are often visually noticeable changes.
Examples are: alert, and timer.
These include sub-windows for your main document and are, for example, alertdialog or dialog.
I'll document these as existing, but you should not use these. Browsers should only use these to identify specific things.
Let's dive deeper into all the document structure roles we can find.
The following ones do not have semantic variants at the time of writing. (This might change over time)
And the following should only be used as a last resort. They should have some semantic alternative. (I'll describe the semantic versions behind each)
<article>)<td>)<th scope="col">)<dfn><figure> instead)<h1> - <h6>)<img> or <picture> instead)<ul> or <ol> instead)<li> instead)<meter> instead)<tr>)<thead>, <tfoot> and <tbody>)<th scope="row">)<hr>)<table>)<dfn>)And there are a few more that you rarely will ever need to use and should try to avoid.
Let's take a look at all the available widget roles.
The following widget roles should be avoided as they have semantic alternatives.
Then there are some composite widget roles, which should always include a combination of others.
As mentioned, the landmarks often have semantic alternatives that should be used.
But for completeness, here is the list.
<header>)<aside>)<footer>)<form>)<main>)<nav>)<section>)The live region roles are exciting and should be used only for dynamically changing elements.
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter