Links need href

ZMD010

Every <a> element must have a non-empty href attribute to function as a link and be keyboard-focusable.

✅ Good

<a href="/learn-more">Learn more</a>

❌ Bad

<a>Learn more</a>

When: An anchor tag lacks an href or it is blank

Warning: <a> tag missing non-empty href attribute

Solution: Add a valid href value

Why it matters

Accessibility: Anchors without href are skipped in focus navigation and not announced as links :contentReference[oaicite:10]{index=10}.

SEO: Search engines only index <a> elements with href, so missing href undermines discoverability.

In brief

  • Goal: Ensure anchor elements are recognized as links by browsers and assistive technologies.
  • What to do: Add a valid URL or fragment value to each <a> via the href attribute.
  • Why: Without href, anchors lack focusability and are not announced as links.

Intent

Prevent misusing <a> tags as non-link elements, maintaining both accessibility and semantic correctness.

Benefits

  • Keyboard accessibility: anchors with href are included in tab order :contentReference[oaicite:8]{index=8}.
  • Screen-reader clarity: links announce their presence and destination via href :contentReference[oaicite:9]{index=9}.
  • Usability: users expect clickable text to navigate to resources.

Techniques

  • WCAG G203: Ensure <a> elements have an href attribute per WCAG 2.4.4.
  • axe-core rule: href-no-hash: Disallow anchors without valid URIs or URL fragments.

HTML Semantics

The href attribute on <a> defines the hypertext link; without it, the element does not represent a hyperlink.

Tips & edge cases

  • Avoid using <a> without href; if you need a button, use <button> instead.
  • Validate your code with axe or pa11y to catch missing href values automatically.