Anchors with `onclick` but no `href` are not accessible or usable as links for all users and devices.
By Seoxpert Editorial · Published
Links without `href` are not accessible to keyboard users and are not recognized as links by screen readers. This breaks standard browser behaviors like opening in a new tab or copying the link, harming both accessibility and user experience.
Leaving this unresolved excludes keyboard and assistive tech users, and may reduce site usability and accessibility compliance.
Automated crawlers scan for `<a>` elements with an `onclick` attribute but missing or empty `href` attributes.
Problem: Anchor with onclick but no href
<a onclick="doSomething()">Click me</a>Fix 1: Use button for actions
<button type="button" onclick="doSomething()">Click me</button>Fix 2: Use anchor with href for navigation
<a href="/destination" onclick="navigateSPA(event)">Go to page</a>
<script>
function navigateSPA(e) {
e.preventDefault();
// SPA navigation logic here
}
</script>Without an href, anchors are not focusable by keyboard and are not announced as links by screen readers, making them inaccessible.
Yes, but you must still provide a valid href for accessibility and standard browser behavior, even if JavaScript intercepts the click.
Use a button for actions that do not involve navigation, such as submitting forms or triggering UI changes.
While not a direct ranking factor, poor accessibility and broken navigation can negatively impact user experience and site reputation.
Run a scan to see if Anchors with `onclick` But No `href` affects your pages.
Scan my website →