Non-interactive elements like <div> with onclick handlers are inaccessible to keyboard and assistive tech users.
By Seoxpert Editorial · Published
Using <div> or <span> with onclick handlers makes interactive controls inaccessible to keyboard and screen reader users. This harms usability, excludes users with disabilities, and fails WCAG 2.1 AA accessibility requirements, which can impact SEO and legal compliance.
Users relying on keyboards or assistive technologies cannot activate these controls, leading to poor accessibility and potential SEO penalties.
The issue is detected by scanning for non-interactive elements (e.g., <div>, <span>) with onclick attributes but lacking role="button".
Problem: Non-interactive element with onclick
<div onclick="doSomething()">Click me</div>Fix: Use a semantic button
<button type="button" onclick="doSomething()">Click me</button>Alternative Fix: Accessible div (not recommended)
<div role="button" tabindex="0" onclick="doSomething()" onkeydown="if(event.key==='Enter'||event.key===' '){doSomething();}">Click me</div><div> elements are not focusable or announced as interactive, so keyboard and assistive tech users can't activate them.
Role="button" helps, but you must also add tabindex="0", keyboard event handlers, and a visible focus indicator for full accessibility.
Yes, <button> elements can be styled with CSS to match any design while retaining accessibility.
Indirectly, yes. Poor accessibility can impact user experience signals and compliance, which search engines consider.
Run a scan to see if Click Handlers on Non-Interactive Elements (`<div onclick>`) affects your pages.
Scan my website →