Welcome, everyone. Thank you for joining me here today.
Today I'm going to be talking about Nested Interactive Elements in Nightmare Accessibility. We only have so much time for this talk, so we're going to jump in really quick and get started.
But before we really get started, let me just tell you about myself. My name is Kat Johnson. I'm a senior front-end engineer at Khan Academy and I love talking about accessibility and how to create accessible websites.
So let's dive right in. But before we get into sort of the meat of how to fix this issue, let's talk about what are Nested Interactive Elements? Because you might not have heard about them.
Nested Interactive Elements in very simplistic terms is just interactive elements nested within each other. So, for instance, it's having a link within a link or a button within a button.
Here's a little slice of code that kind of shows this. The reason this structure is really problematic is because it's incorrect HTML.
In the really early days of websites and the web, it didn't really make sense to nest buttons inside of buttons or links inside of links. There really wasn't a use case for this. But as the web has evolved, we are seeing this more and more in a lot of our user experiences around the web, from Google to this website that I really like using called The Mountaineers.
You'll find a lot of buttons or links inside of links and some of these little button menus.
But you might be asking the question, what's the big deal? It might be semantically incorrect HTML, but me as a user, I never had any issues using this experience. I'm able to click and navigate and use a lot of these nested buttons. So it doesn't seem to really be a big problem.
The bigger problem is because it's incorrect HTML, it really messes with a lot of screen readers and other assistive tooling. Because it's incorrect HTML, a lot of screen readers and other assistive tools, when they read your HTML, it doesn't know how to read out that information and how to convey it to the user.
Usually this will cause a lot of errors and a lot of miscommunication for a lot of assistive tooling, making it really difficult for users to interact with your website.
So now you must be thinking, well, I could probably fix this. I'll just remove the role equals button or I'll use a generic HTML div and leave on click functionality. That should fix this accessibility issue, right? Well, wrong. Do not do this.
You might be fixing the issue of nested interactive elements, but now you're hiding interactive elements from other screen readers and other assistive tools.
So when a user navigates your website with narrator or NVDA, they'll go over this element within your HTML, and it won't announce that it's a button that they need to click on. They'll hide that information and really degrade the experience for your website and cause more accessibility issues.
Comments