Skip to content

Anchor tags should not be used as buttons #104

@alvaromontoro

Description

@alvaromontoro

Describe the new a11y feature or project enhancement

Anchor tags should not be used as buttons, it is bad for accessibility and usability. Links should redirect to a resource/page, if they don't they probably should be buttons.

Describe the solution you'd like

Display a warning if a link is being used as a button. Examples of links being used as buttons:

<a href="#">Do something</a>

<a href="javascript:void(0)" role="button">Do another thing</a>

<a href="javascript:doSomething(0)">Do another thing</a>

Basically, what should trigger the warning would be:

  • An anchor tag with href="#" (a link that doesn't go anywhere)
  • An anchor tag with href starting with "javascript:" (a link that calls a function instead of redirecting)
  • As a bonus, any anchor tag (or any element different than a button or input) that has role="button" should probably display the warning.

Link(s)

Metadata

Metadata

Assignees

Labels

a11y featureNew feature or request for an a11y checkgood first issueGood for newcomers

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions