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).
<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.
- Landing pageLoads fine
- Tab to CTADiv is skipped, never focused
- Form opensNever triggered
- 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
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.
Try Enter and Space
On focusable controls, press Enter and Space. A real button reacts to both.
Inspect the element
Right-click the button, choose Inspect, and look at the tag. A
divorspanwith a click handler and noroleis the issue.Run an accessibility scanner
Use Lighthouse in Chrome DevTools, axe DevTools or WAVE. They flag missing roles, non-focusable interactive elements and missing names.
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.
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
<button type="button" class="btn" onclick="openQuoteForm()">Get a quote</button>.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;
}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.
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.
Edit the theme code
Go to Online Store > Themes > Edit code. Search for
onclickorrole="button"in sections and snippets and replace div or span triggers with<button type="button">.Check apps
If an app injects the div, contact the app developer or test a replacement.
Check custom HTML tags
Open Tags and look for Custom HTML tags that inject widgets or buttons. Replace any div buttons in that markup with real buttons.
Update click triggers
If your click trigger matches a CSS selector like
div.btn, update it tobutton.btnafter the change, or tracking will stop.
Use a Link Block or Button element
In the Add panel, use Button or Link Block instead of a Div Block with an interaction. Set the link target or use a custom attribute for actions.
Replace interaction triggers
If a Div Block has a click interaction, wrap it with a Button element or change its tag in the Element Settings panel.
Use the Button element
In the funnel or website builder, add the Button element instead of a clickable Row, Column or Text. Set its action to a link or popup.
Review custom code
Search Custom Code blocks for
onclickon div or span tags and replace them.
Use the Button element
Add a Button from the Add panel rather than making a box or strip clickable. Set its link in Link settings.
Check custom code
Review any embedded HTML for div click handlers.
Use the Button block
Add a Button block and set its URL. Avoid code injection that adds click handlers to divs.
Review Code Injection
Open Settings > Advanced > Code Injection and replace any div-based buttons.
Replace with button or a
Search your codebase for
onclickandaddEventListener('click'on div and span selectors. Change the markup to<button type="button">, or<a href>for navigation.Last resort: add role, tabindex and keys
If you cannot change the element, add
role="button",tabindex="0"and key handlers as shown below.
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
- 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
- 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.
Related issues
- PRF-324Icon-only buttons without accessible namesFix guide
- PRF-325ARIA roles misused (role=button on links, aria-hidden on focusable)Fix guide
- PRF-311Focus outline removed (outline:none)Fix guide
- PRF-313Form cannot be completed with keyboard onlyFix guide
- PRF-312Keyboard trap in modal or widgetFix guide
- PRF-314Illogical focus orderFix guide