Skip to content

Latest commit

 

History

History
41 lines (28 loc) · 1.58 KB

File metadata and controls

41 lines (28 loc) · 1.58 KB

Linter Rule: Require href attribute on <a> tags

Rule: html-anchor-require-href

Description

An <a> element that has an href attribute represents a hyperlink (a hypertext anchor) labeled by its contents. Links should go somewhere. If you want to perform an action without navigating the user to a new URL, use a <button> instead.

Rationale

Anchor tags without an href attribute are not focusable via keyboard navigation and are not visible to screen readers. This makes them inaccessible to users who rely on assistive technologies.

Examples

✅ Good

<a href="https://alink.com">I'm a real link</a>

🚫 Bad

<a>Go to Page</a>
<a data-action="click->doSomething">I'm a fake link</a>

References