Empty Href Attribute on Links

Empty Href Attribute on Links

WCAG Focus: WCAG 2.1.1 (A), 4.1.2 (A)

Writing <a href="">Click to expand</a> or <a href="#">Toggle</a> as a placeholder for a JavaScript action creates broken navigation. An empty href="" causes browsers to reload the current page completely, while href="#" jumps the viewport back to the top of the page.

Why This Pattern Violates WCAG

WCAG 2.1.1 Keyboard (Level A) and 4.1.2 Name, Role, Value (Level A) expect buttons to trigger actions and links to navigate to real destinations.

Screen reader users who activate a link expecting navigation instead get bounced to the top of the page or trigger an unintended reload.

Code Comparison

Inaccessible Empty Href Anchor

<a href="" onclick="toggleFaq(event)">Show Answer</a>

Compliant Button for In-Page Actions

<button type="button" aria-expanded="false" onclick="toggleFaq()">Show Answer</button>

How to Fix It in WordPress

  • Convert action triggers with href="" or href="#" into semantic <button type="button"> elements.
  • Ensure real navigation links always carry a valid, non-empty destination URL.

Finding This Issue Automatically

Copied code snippets and theme toggles frequently leave behind empty href="" attributes. Running the WP ADA Compliance Check plugin identifies anchor tags with empty href attributes across your WordPress site so you can turn them into clean buttons or valid links.

Subscribe

Subscribe to receive daily Web Accessibility - Did you know? articles in your inbox.

Cart Accessibility Tools
hide