Warning Link with an empty href attribute

Why href="" links to the page's own URL and reloads it, and how that differs from a link with no href at all.

The validator flags any <a href=""> — an anchor with the href attribute present but set to an empty string.

Example

<!-- Wrong: reloads the current page when clicked -->
<a href="" onclick="doSomething()">Click</a>

<!-- Right, if it's meant to navigate -->
<a href="/destination">Click</a>

<!-- Right, if it's meant to be a non-navigating control -->
<button type="button" onclick="doSomething()">Click</button>

Why it matters

An empty href is not the same as no href at all. A relative URL of "" resolves to the current page's own URL, so clicking the link navigates to itself — in practice, a full page reload, which discards any in-page JavaScript state and interrupts whatever the click handler was trying to do. This pattern shows up most often on links that were only ever meant to be JavaScript-driven controls, where href="" was added just to make the element look clickable or focusable. A <button> is the correct element for a control that doesn't navigate anywhere; an <a> with no href at all is also valid syntax and won't trigger a reload, but it loses default link semantics like keyboard focusability.

Frequently asked questions

Why not just use href="#" instead?

href="#" avoids the full reload but still jumps to the top of the page (or shifts scroll position) unless the click handler calls preventDefault(). Neither href="" nor href="#" is the right tool for a non-navigating control — use a <button> instead.

Is <a> with no href attribute at all a problem?

No — that's valid and is not flagged by this check. An <a> with no href is simply not a hyperlink; it renders as plain inline text with no default navigation behavior, which is a legitimate (if unusual) choice for a placeholder link.