#34 a button is not a link

submitted on by Moritz Glantz

Bad code

<button type="button" onclick="window.open('https://example.com/other-page')">Link target description</button>

Issues and how to fix them

  1. A button opening a link will be unexpected behavior for screen reader users. No matter how it is styled.
  2. Links disguised as buttons won’t show up in the link list of a site in assistive technologies.
  3. Use links for navigation to other pages or sections, and buttons for actions performed on the current page or within the application.

Good code

<a href="https://example.com/other-page">Link target description</a>