Skip to main content
Viewing options

When to use HTML buttons vs. links for accessibility

Graphic on a yellow background illustrating the difference between a Button (represented by a black, rectangular shape) and a link (represented by the word 'link' in blue, underlined text).

TL:DR

The choice is always defined by what the element does, not how it looks.

You should use an HTML link <a>) when the element's primary function is to navigate the user to a new page or a different location on the current page. Conversely, you should use an HTML button (<button>) when the element's primary function is to perform an action or change the state of the current page, such as submitting a form, toggling a menu, or deleting an item.

When to use an <a> (link)

Use an <a> element (anchor) when the user expects to navigate to a different URL, page, or a section within the current page.

ScenarioSemantic purposeCorrect HTML
Navigating to a new pageTakes the user to a different resource.<a href="/checkout">Proceed to Checkout</a>
Downloading a fileNavigates the browser to the file's location to start the download.<a href="/document.pdf" download>Download Report</a>
Navigating within the pageMoves the user to a different section on the current page (a jump link).<a href="#contact-us">Go to Contact Form</a>

Accessibility benefits of <a>

  • Keyboard control: works natively with the Enter key.
  • Announcement: screen readers announce the element as "link", telling the user they are about to leave or move within the current context.

When to use a <button> (button)

Use a <button> element when the user is expected to perform an action or change the state of the current page, without causing a full page refresh or navigation.

ScenarioSemantic purposeCorrect HTML
Navigating to a new pageTriggers the form to be sent to the server.<button type="submit">Send Message</button>
Downloading a fileShows/hides content (like expanding a menu, collapsing an accordion, or opening a modal).<button aria-expanded="false">Show Filters</button>
Navigating within the pageRuns client-side script that modifies data (e.g., adding an item to a cart, deleting a row, liking a post).<button onclick="addItem()">Add to Cart</button>

Accessibility benefits of <button>

  • Keyboard control: Works natively with both the Enter and Spacebar keys.
  • Announcement: Screen readers announce the element as "button", indicating that an immediate action will occur upon activation.

Common mistakes to avoid

The most frequent accessibility mistake is using the wrong element and trying to fix it with ARIA. 

MistakeWhy it’s wrongThe fix
Link acting as a button<a href="#" onclick="deletePost()">Delete</a>Screen reader announces "link," confusing the user who expects navigation but gets an action.
Button acting as a link<button onclick="window.location.href='about.html'">About</button>Screen reader announces "button," confusing the user who expects an action but gets navigation. Also, users often instinctively hit Enter on links, not the Spacebar needed for buttons.

If you are still unsure, then the acid test is to ask yourself:

If disabling JavaScript still allows the element to complete its task (i.e., navigate to a new page), it should be a link. If the element relies on JavaScript to perform an action on the page, it should be a button.

Article by Simon Leadbetter

The Accessibility Guy at Kindera

Simon Leadbetter