Skip to content

ACT-009 Give everything people click to go somewhere or to act the role of a control in code

Level
Rule
Verdict
Requirement
Status
proposed, version 1.0.0

Rule

Everything people click or tap to go somewhere or to act has a control role in code, such as link or button. Something shown as a link whose only job is to take people to another address has the link role.

Examples

Live examples built with Justified's components. Try them with the mouse, the keyboard or a screen reader.

Do: The title is a link, the actions are buttons

On the loan card, The Dispossessed is an <a href>, and Renew loan and the star are buttons. The list under the card is what a screen reader’s lists of links and buttons hold. Tab reaches all three. A plain click on the link only reports where it would go, so Storybook stays put; the real href is still there, so Ctrl or Cmd click opens the address in a new tab, as on any link (Storybook has no such page).

Don't: The whole card has the click handler

The Dispossessed

Due back 3 December

Click anywhere on the card and it says where it would go, but the card is a plain article with onClick. The list is empty of links: nothing here is a link, so a screen reader reads the title as text. Tab skips the card, so this opening works with a pointer only. The one button, Renew loan, is real and stops the click from reaching the card.

Do: A link that looks like a link is one

Opening hours

Monday to Friday 9 to 18, Saturday 10 to 14.

All branches is Button variant="link" asChild around an <a href>. It looks like a text link and is announced as one. Download loan history (CSV) is a link to the file, as it still goes to an address. Plain clicks report where they would go; Ctrl or Cmd click, a middle click and Copy link address work for real (Storybook has no such page).

Don't: A link-looking button that goes by script

Opening hours

Monday to Friday 9 to 18, Saturday 10 to 14.

All branches looks the same, but it is Button variant="link" onClick that changes the address by script. It works with Tab and Enter, but a screen reader calls it a button, and it is not in the list of links. A middle click or Copy link address has no address to use.

Don't: Click handlers on an anchor, a span and an icon

The Dispossessed

Due back 3 December. Late fees

Renew loan is an <a> with no href, Late fees an underlined span and the star an icon, each with onClick. A click with a pointer works. In HTML none of them has a role, so the list is empty. Chrome guesses link for the anchor from its click handler, but Tab still cannot reach it, and other browsers read it as text. Tab reaches none of the three: this example cannot be used with a keyboard at all.

Why

A screen reader tells people what each thing is before they use it: "link", "button", "menu item". It also lets them jump through a list of every link or every button on the page. A div, span or image with a click handler is none of these. It has no control role: it is read as plain text, if it is reached at all, and it is missing from those lists, so the person may never learn that it does anything. WCAG 2.2, 4.1.2 Name, Role, Value requires that every control, scripted ones included, has a role software can work out. The Working Group lists a generic element made clickable by script without a role as a failure (F59). It also fails anything presented as a link that reaches its target by script while its role is not link (F42), even when it works from the keyboard. An anchor with no href is not a link in HTML, so it has no control role either. The criterion asks for the role, not for a native element; building with <button> and <a href> is the Working Group's advice and ours. That every control also works from the keyboard (2.1.1 Keyboard) is KBD-001. 1.3.1 Info and Relationships supports this rule, since a fake link loses what the page shows about it.

Do

  • In a library's app, My loans shows each book as a shadcn Card. The book's title is a Link to its page and Renew loan is a Button. A click elsewhere on the card may open the book's page as a shortcut, as KBD-001 allows.
  • Under the opening hours, All branches looks like a text link and is one: <Button variant="link" asChild><Link href="/branches">All branches</Link></Button> renders an <a href>.
  • The star that adds a book to Wish list is a Button size="icon" with the lucide Star inside, named as ACT-001b says.
  • Wrap a real Button in DialogTrigger, DropdownMenuTrigger or PopoverTrigger when you use asChild. Without asChild they render a <button> themselves.
  • Our advice, which is also the Working Group's: use <button> and <a href>. The adapter's Button renders <button type="button">, or the element you give it with asChild, and Next.js and React Router Link render <a href>.
  • If a control must be built by hand, it needs all of it: role="button" or role="link", tabIndex={0}, Enter (and Space for a button), aria-disabled when it is off, any other state it has (VIS-008a), and a name (ACT-001b). Enter and Space are our advice; keyboard use is KBD-001. That can meet the criterion, but it is the worse way.
  • A link that downloads a file, such as Download loan history (CSV), is still a link: <a href="/loans.csv" download>.
  • Which of the two to pick for a given job is ACT-009a for going somewhere and ACT-009b for acting in place.

Don't

  • Put onClick={() => router.push("/books/" + book.id)} on the Card and nothing inside it that is a link.
  • Write <a onClick={renewLoan}>Renew loan</a> with no href. It has no role in HTML and takes no focus.
  • Build All branches as <Button variant="link" onClick={() => router.push("/branches")}>. It looks like a link and goes somewhere, but a screen reader calls it a button and it is not in the list of links.
  • Make Late fees an underlined span with cursor-pointer that calls navigate("/fees").
  • Put onClick straight on the lucide Star icon.
  • Put a span inside PopoverTrigger asChild, so the trigger loses the button it would have rendered.

Exceptions

  • A pointer shortcut. A click on a card, a row or a backdrop may do what a real control nearby already does. The control carries the role; the shortcut needs none. KBD-001 and TBL-003 say the same.
  • Act, then move. A control whose job is to save, send, delete or sign out, or send typed input such as Search, stays a button when a page follows, also when it looks like a link (see ACT-009a).
  • Table cells and rows. Do not put role="button" or role="link" on a th, tr or TableRow to make it clickable. Put the control inside, as TBL-002 and TBL-003 say.
  • Neighbouring rules. The keyboard half is KBD-001, the name is ACT-001b, and link text is TXT-003.

Verdict

Requirement. Only the judges decide; the expert witnesses are shown but do not vote. How verdicts work

Stances on ACT-009
SourceRoleStancePage
WCAG 2.2LawRequires4.1.2 Name, Role, Value
WCAG 2.2LawSupports2.1.1 Keyboard
WCAG 2.2LawSupports1.3.1 Info and Relationships
Material DesignJudge SupportsAccessibility designing: elements
Apple Human Interface GuidelinesJudge No position
Carbon Design SystemJudge SupportsButton: usage
Link: usage
GOV.UK Design SystemExpert witness SupportsButton
Nielsen Norman GroupExpert witness No position

Each stance links to the page it rests on, read on the date in the source register. This page never repeats what a source says; read the source itself.

History

  • Version 1.0.0, : First version.

Last checked against the other rules for conflicts on .

More in Actions: 11 rules and 4 guidelines · All rules