The href-less Anchor Anti-Pattern
Why a fake link breaks keyboard and screen reader users.
The href-less Anchor Anti-Pattern is a free Web Accessibility Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Web Accessibility Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
The Fake Link
A common anti-pattern is an anchor with no href, wired up with a click handler to act like a button. It looks fine but breaks things.
<a onclick="openMenu()">Menu</a>No href, No Link
An anchor only counts as a real link when it has an href. Without one, the browser does not treat it as interactive at all.
It Falls Out of Tab Order
An href-less anchor is not focusable, so keyboard users tabbing through the page skip right past it and can never reach it.
The Keyboard Cannot Fire It
Even if you force focus onto it, a fake link ignores Enter and Space by default, so keyboard users still cannot activate it.
Screen Readers Get Confused
Without an href, a screen reader may not announce the anchor as a link at all, so users never learn it is something they can use.
The href Pound Hack
Some patch it with an href of just a hash. That makes it focusable but it also jumps the page to the top, which is jarring.
<a href="#" onclick="openMenu()">Menu</a>The Real Fix
If the control performs an action, use a real button. You get focus, keyboard support, and the correct role for free.
<button type="button" onclick="openMenu()">Menu</button>When It Should Be a Link
If the control truly navigates, keep the anchor but give it a real href pointing to the destination.
<a href="/menu">Menu</a>Why People Do This
Developers often pick an anchor for its underline styling. But you can style a button instead, without sacrificing accessibility.
Cursor Lies Too
An href-less anchor even loses its pointer cursor by default, hinting to sighted users that nothing is really clickable here.
The Takeaway
Do not fake interactivity. Choose a real button for actions or an anchor with an href for navigation, and skip the workarounds.
Quick Check
Why is an anchor with no href but a click handler a problem?
Recap
An href-less anchor is a fake link: unfocusable and keyboard-dead. Use a button for actions, a real href for navigation. ✅
Frequently asked questions
Is the “The href-less Anchor Anti-Pattern” lesson free?
Yes — the full text of “The href-less Anchor Anti-Pattern” is free to read here on the web, and the Web Accessibility Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Web Accessibility Academy course, upgrade to CoddyKit PRO.
What will I learn in “The href-less Anchor Anti-Pattern”?
Why a fake link breaks keyboard and screen reader users. You practise Web Accessibility Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Web Accessibility Academy?
No prior experience is required. Web Accessibility Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “The href-less Anchor Anti-Pattern” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Web Accessibility Academy lesson?
Yes. Every Web Accessibility Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Links Go Places, Buttons Do Things
- Link Text That Makes Sense Out of Context
- Buttons That Announce What They Do
- The href-less Anchor Anti-Pattern