Skip to content
easeweb
Search topics

Buttons announced as links that Space can't press

A pill that opens a form is built on a link with href="#", so a screen reader calls it a link and Space scrolls the page instead of pressing it.

WCAG 2.2
SC 4.1.2A
Required by
Section 508 · EN 301 549 (EU)
Broken <a href="#" class="pill">
The accessibility problem illustrated: No vision:Where will this link take me?
01

The problem

Screen reader users are told a control is a link that will take them somewhere, when it opens a form, and keyboard users who press Space scroll the page instead.

02

Try it

Press Tab to reach “Email me when it’s back”, then press Space. Then try Enter.

Does Space open the form, or does the page scroll? The panel shows what a screen reader calls the pill: a link or a button.

Broken Can you fix this?

BrokenA link that points nowhere, drawn as a pill

Linen tote

$48

Sold out

Email me when it’s back

About this bag

A roomy tote in washed linen that softens with every wash. It folds flat into its own pocket, so it goes everywhere.

  • Washed linen, 40 by 38 cm
  • Inside pocket with a zip
  • Long handles that fit over a shoulder

Delivery and returns

Free delivery on orders over $60. Returns are free within 30 days, in the original packaging.

Care

Machine wash cold and hang to dry. A warm iron brings back the crisp look.

Email me when it’s back

We’ll send one email when the linen tote is back in stock.

Screen reader says:

(Tab to the pill)

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Build the control that acts as a button, or give the link role="button" and press it on Space.

  1. 1A control that opens, changes or sends something has the button role; a link goes to an address.
  2. 2Enter and Space each press it once, and Space never scrolls the page.
  3. 3Keep the look: the pill stays a pill, whichever element it is.
Before A link that points nowhere, drawn as a pill
<p class="stock">Sold out</p><a href="#" class="pill notify">  Email me when it's back</a><dialog id="notify" aria-labelledby="notify-title">  …</dialog>
After

A button

<p class="stock">Sold out</p><button type="button" class="pill notify">  Email me when it's back</button><dialog id="notify" aria-labelledby="notify-title">  …</dialog>

Why this fix: Use native HTML first

The patch that is not a fix
<a href="#" role="button" class="pill notify">  Email me when it's back</a>

Fixing this with an AI coding assistant? Get this guide as Markdown, or get every guide in your coding agent.

04

Verify the fix

4 checks, no mouse.

Test with: Keyboard, Screen reader

0 of 4 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 or link component changes.

Limits

This guide covers a link that does a button's job. The reverse, a button that only takes people to another page, is the same topic seen from the other side, and is meant for a later guide: it is announced as a button, and it can't be opened in a new tab or found in the list of links. For a div or span with a click handler and no role at all, see div buttons that can't be reached with Tab. Links that filter or sort the page in place belong to the topic on links that update the page, and a button with no words to 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.

Keep this fixed as your code changes.

Turn guides like this into rules your coding agents and CI follow, then have the result retested with a keyboard and screen readers.

How retests work