Skip to content
easeweb
Search topics

Div buttons that can't be reached with Tab

A Save control built from a div with a click handler takes no Tab stop and ignores Enter and Space, and role="button" on its own doesn't change the keys.

WCAG 2.2
SC 2.1.1ASC 4.1.2A
Required by
Section 508 · EN 301 549 (EU)
Broken <div>
The accessibility problem illustrated: Motor:How do I save my changes?
01

The problem

Keyboard users cannot save their work, and screen reader users are not told there is a button

02

Try it

Put the mouse aside and save your settings with Tab, Enter and Space

  • Broken 1: Tab on from Display name. Does focus stop on “Save changes”? The panel shows what a screen reader says when it reads down to it.

  • Broken 2: Tab on from Display name to “Save changes”, then press Enter, and Space. Focus stops and a screen reader says “button”, but does anything save?

  • Apply a fix. Tab to “Save changes” and press Enter, then Tab away and back and press Space: each one saves.

Broken Can you fix this?

Save changes

Help

Reading down to Save changes, a screen reader says:

Save changes

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Let Tab reach Save, and Enter and Space press it

Before

A div that only listens for clicks

<div class="save-control">  Save changes</div><p id="save-status"></p>
What is wrong4 points

It looks like a button only to people who can see it and use a pointer.

  • A keyboard user can't reach Save: a div is not in the tab order, so Tab passes it by.
  • A screen reader user isn't told it is a button: with no role, "Save changes" is read as plain text.
  • Enter and Space don't save: on a div, neither key becomes a click.
  • Even when it saves, a screen reader user isn't told: the result is written into a plain paragraph, so it is shown but not announced.

The same goes for a span, an icon drawn with <i> or <svg>, a whole product card that opens a quick view, and an a with no href: none of them takes focus or has a role until you give it one.

After

A native button

<button type="button" class="save-control">  Save changes</button><p id="save-status" role="status"></p>
How it is fixed4 steps
  1. Replace the div with a button type="button". It is in the tab order and has the button role, and its click handler also runs for Enter and Space, so the script stays as it was and no key handling is needed.
  2. In the CSS, add font: inherit, since a button doesn't take the page's font on its own. The rest of the div's styles, its border included, now replace the browser's, so the button looks as the div did.
  3. Give it a ring on :focus-visible.
  4. Add role="status" to the paragraph the result is written into, so the result is read out.

This fixes both Befores and passes 2.1.1 and 4.1.2. The status region must be in the page before its text changes, or the result may not be announced. A native button can also take the look a custom control is often kept for: the div's own styles carry over, and only the font needs setting.

Why this fix: Use native HTML first

04

Verify the fix

6 checks, no mouse.

Test with: Keyboard, Screen reader, Zoom, Forced colors

0 of 6 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the shared button component changes.

How screen readers handle role="status"

Limits

This is a starting pattern, not a guarantee for every application. The snippets omit application-specific data handling. Parts of a larger widget that take only clicks have their own guides, since the keys they need differ: carousels that keyboard and screen reader users can't use, toolbars of clickable icons a keyboard can't reach and product photo thumbnails that need a mouse or say nothing. A button that is reached but has no words is covered in icon-only buttons with no accessible name. Test the complete journey with your target assistive technology.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

EaseWeb service

Fixed it? Keep it from coming back.

I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.

See the service