Links with no destination, driven by JavaScript
WCAG 2.1.1, 4.1.2 (A) · EN 301 549 9.2.1.1
There are <a> elements with no href that still respond to clicks.
Why it matters
An <a> without href does not receive keyboard focus and is not announced as a link. Anyone navigating with Tab simply cannot reach it: for that person the element does not exist.
How to fix it
If it navigates somewhere, give it a real href. If it performs an action on the page (opening a menu, a modal), use a <button>, which is keyboard-accessible already.
<a onclick="openMenu()">Menu</a><button type="button" onclick="openMenu()">Menu</button>Related
- Image button with no alternative text
- Embedded frame with no title
- Form fields with no label
- Buttons with no name
Does your shop have this failure?
Check for free, along with the other 54 rules. No sign-up.