Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Buttons made from divs without role or keyboard support: fix

PRF-322Medium impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

Browsers give a real <button> three things for free: it appears in the Tab order, it fires on Enter and Space, and it is announced to screen readers as a "button". A <div onclick=...> has none of these. It only reacts to a mouse or a touch.

This is common in page builders, custom themes, sliders, popup widgets and component libraries where designers style a div to look like a button. It fails WCAG 2.2 success criteria 2.1.1 (Keyboard) and 4.1.2 (Name, Role, Value).

The problem: a div that only looks like a buttonhtml
<div class="btn" onclick="openQuoteForm()">Get a quote</div>

Why it costs you leads or sales

If the button opens a form, adds to cart or starts checkout, anyone who navigates by keyboard, switch device or screen reader cannot start. They leave, and you never see them in your reports because nothing broke for mouse users.

It also affects people with temporary injuries, power users who tab through forms, and some voice control tools that rely on accessible names and roles. In some countries, inaccessible checkouts also carry legal risk.

Where a keyboard visitor gets stuck
  1. Landing pageLoads fine
  2. Tab to CTADiv is skipped, never focused
  3. Form opensNever triggered
  4. Lead submittedNever reached

The visitor tabs through the page but the div button is skipped, so the funnel stops.

How to check if your site has it

Manual checks (about 10 minutes)
  1. Tab through the page

    Click the address bar, then press Tab repeatedly. Every button and link should get a visible focus. If your main CTA is skipped, it is probably a div.

  2. Try Enter and Space

    On focusable controls, press Enter and Space. A real button reacts to both.

  3. Inspect the element

    Right-click the button, choose Inspect, and look at the tag. A div or span with a click handler and no role is the issue.

  4. Run an accessibility scanner

    Use Lighthouse in Chrome DevTools, axe DevTools or WAVE. They flag missing roles, non-focusable interactive elements and missing names.

  5. Test with a screen reader

    Try VoiceOver (Mac, iPhone), NVDA (Windows, free) or TalkBack (Android). A div button is read as plain text, not as a button.

How to fix it

Use the right element for the job. Use <button> for actions on the page (open a form, add to cart, submit). Use <a href> for navigation to another URL. Style it with CSS to look the same.

Div button vs real button

Before

  • Not in the Tab order
  • Ignores Enter and Space
  • Read as plain text by screen readers

After

  • Focusable by default
  • Enter and Space both work
  • Announced as a button with its name
The fix: a real buttonhtml
<button type="button" class="btn" onclick="openQuoteForm()">Get a quote</button>
Make the button look like your old divcss
.btn {
  font: inherit;
  border: 0;
  cursor: pointer;
  background: #0b5fff;
  color: #fff;
  padding: 12px 20px;
  border-radius: 6px;
}
.btn:focus-visible {
  outline: 3px solid #111;
  outline-offset: 2px;
}
Fix by platform
  1. Use the native button block or widget

    In the block editor use the Buttons block (it outputs a link). In page builders, choose the Button widget rather than a styled Text or Column element with a click action.

  2. Fix theme or plugin templates

    If the div comes from your theme, edit it in a child theme and replace the div with a button. Report it to the plugin author if it is plugin output.

Last resort: make an existing div behave like a buttonjavascript
const el = document.querySelector('.btn');
el.setAttribute('role', 'button');
el.setAttribute('tabindex', '0');
el.addEventListener('keydown', (e) => {
  if (e.key === 'Enter') {
    e.preventDefault();
    el.click();
  } else if (e.key === ' ') {
    e.preventDefault(); // stop page scroll
    el.click();
  }
});

How to confirm it's fixed

Verification checklist
  • Tab reaches the button in a logical order
  • A visible focus outline appears on it
  • Enter and Space both trigger the action
  • Space does not scroll the page
  • A screen reader announces its name and "button"
  • Lighthouse or axe no longer reports it
  • Click tracking still fires if your trigger used a div selector

How to prevent it happening again

Habits that keep it fixed
  • Add a lint rule such as eslint-plugin-jsx-a11y (click-events-have-key-events, no-static-element-interactions) if you use React
  • Make "use native elements first" part of your design and code review checklist
  • Run axe or Lighthouse in your build or before each release
  • Do a quick Tab-key pass on every new landing page and checkout change
  • Choose page builder widgets that output real buttons or links

How FunnelGuard handles this

This issue is outside what FunnelGuard checks. FunnelGuard runs your real customer journeys on a schedule and checks steps, tracking hits and lead delivery. Spotting missing roles or keyboard support in markup needs a different kind of tool: an accessibility scanner such as axe, WAVE or Lighthouse, plus a manual keyboard and screen reader test.

What FunnelGuard can do is help after the fix. If you swap a div for a button and a click trigger or form step stops working, a scheduled journey check can show where the funnel broke. There is a free plan with 1 site and 2 journeys, and no card is needed.

Questions people ask

Why can't I reach my button with the Tab key?

It is most likely a <div> or <span> with a click handler. Only native interactive elements like <button> and <a href> are focusable by default. Replace it with a <button> or add tabindex="0", a role and key handlers.

How do I make a div act like a button?

Add role="button", tabindex="0", and a keydown handler that triggers the click on Enter and Space. This works but is more fragile than a native <button>, which you should use when you can.

Is it bad to use a div as a button?

Yes, for accessibility. A div has no button role, no focus and no keyboard activation, so it fails WCAG 2.1.1 (Keyboard) and 4.1.2 (Name, Role, Value). Mouse users will not notice, which is why it often goes unseen.

Should I use a button or a link for my call to action?

Use <a href> if it takes the visitor to another page or URL. Use <button> if it performs an action on the current page, such as opening a form, adding to cart or submitting. Both are keyboard accessible by default.

Does role="button" make a div keyboard accessible?

No. The role only tells screen readers what the element is. It does not make the element focusable or respond to Enter and Space. You still need tabindex="0" and key event handling.

How do I find all div buttons on my website?

Search your code for onclick and click listeners on div and span elements, and run an accessibility scanner like axe or Lighthouse. Then tab through key pages and note every control that is skipped.

Will changing a div to a button break my styling or tracking?

It can. Buttons have default browser styles, so reset border, font and background in CSS. If a Tag Manager click trigger or script targets div.btn, update the selector to match the new element.

Can FunnelGuard detect div buttons without keyboard support?

No. This is outside what FunnelGuard checks. Use an accessibility scanner such as axe, WAVE or Lighthouse, plus a manual keyboard test.

Does FunnelGuard catch this?

Other tool

Needs a different kind of tool.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.