But that frustration, that gray area, is part of the reason I started writing this blog, because when I heard the first rule of ARIA is don't use ARIA, I knew what it meant. ARIA is a huge topic with a lot of rules. There are a lot of little rules that contradict each other sometimes. It's very easy to get gotten by ARIA. When I started giving feedback on people's portfolios or side projects, I pop open DevTools, run an accessibility checker, tab through it with a keyboard, use a screen reader, because I know most of the people that are asking for feedback aren't going to give that kind of feedback, and I would go, hey, an ARIA label would be great here. It would make it more accessible. And the developers would look at me and go, I thought I was never supposed to use ARIA.
So about the fifth or sixth time I heard one of my friends say the first rule of ARIA is don't use ARIA, I was like, hey, developers think they're never supposed to use ARIA or use it at all. And he looked me in the eyes and he went, good. Because when you talk to accessibility auditors about ARIA, they'll tell you about the latest mess that was caused by someone who didn't understand ARIA at all just slapping ARIA on the page. So when you hear the first rule of ARIA is don't use ARIA, that means there's probably an HTML element for that, and no ARIA is better than bad ARIA. Let's dig into the first one. You're already using ARIA. By using HTML. And yes, JSX is a templating language, you are using HTML under the hood, so you're all using ARIA. Don't worry about it. Because ARIA rules are the semantics in semantic HTML. They communicate information to computers and to assistive technologies.
So even when you're using an element like a div that has role generic or using role presentation or role none, you're communicating information to computers and assistive technologies. Just like when you look at an outline in a printed document and you see a list or the beginning of a paragraph indented, you don't read that white space out loud and you don't go space, space or tab, tab when you're reading that information, but it's their communicating structure to the page, which is exactly what computers and assistive technologies think a div is there for. And the way that you use semantic HTML communicates even more information. So if you use an address element inside of a footer element, that tells computers and assistive technologies that that's the contact information for that web page. If you use an address outside of a footer element, it's just an address. Before we get to the next part, I have to explain accessible name. You'll hear accessible name or name. And this comes from the accessibility tree. So when you hand a browser a web page, it computes an accessibility tree. And part of that accessibility tree is a name property. The name property comes from a lot of things, depending on what needs a name and what you've used. So the best example is labels because we're all associating labels with our inputs when we use them, so that's how they get their name.
Comments