When you first walked the Concerts page with the keyboard, focus went from Ticket prices straight to the sign-up link and skipped Get tickets. Since then, you’ve made focus visible and given the choir’s controls names that match their text. Get tickets is the one control on the page that still doesn’t work for anyone, whether they use a keyboard, a mouse, or, like Tomás, a screen reader.
In this lesson, you’ll fix it, and on the way you’ll learn what ARIA can and can’t change. By the end, you’ll be able to look at markup that mixes ARIA with native HTML elements and predict what the Accessibility pane reports and what a keyboard user can actually do. Start by looking at what the browser makes of Get tickets today.
Give the Div a Role
To a sighted visitor with a mouse, Get tickets looks like the Ticket prices button above it, because both share the .button class. The markup in concerts.html tells a different story:
<form action="tickets.html">
<div class="button get-tickets">Get tickets</div>
</form>
It’s a <div> inside a form that should take people to the tickets page. Right-click Get tickets, choose Inspect, and open the Accessibility tab. The pane shows the role generic and an empty name. A generic <div> is only a box, so Tomás’s screen reader has nothing to tell him that there’s a control here at all. That fails 4.1.2 Name, Role, Value, at Level A: every control must expose its name and its role to assistive technology.
How would you tell Tomás’s screen reader that this is a button? Most people’s first idea is ARIA’s role attribute. You’ve already used three ARIA attributes, short for Accessible Rich Internet Applications: aria-label, aria-describedby, and aria-hidden. Like them, role is information for assistive technology. It says what kind of thing the element is.
It’s the wrong fix, and you’ll make it on purpose to see why. Add the role to the <div>:
<div class="button get-tickets" role="button">Get tickets</div>