A bench of real elements: Tab, Enter, Space, middle-click. See for yourself which is a button, which is a link, which is just a box. An interactive Button vs…
<button> and <a href> come with focus, Enter and Space, a role for screen readers, middle-click, "Open in new tab" and the Back button. <div onclick> gets none of it. Keyboard users, screen reader users and people who open lots of tabs are real users, and the wrong element locks them out.
One question: go to an address, or change state?
<a href="#"> + onclick for an action href="#" is an address: middle-click opens a tab of the same page, without preventDefault the page jumps to the top, and screen readers say "link" though it goes nowhere. An action is <button type="button">. A jump to a section is <a href="#features"> with an id that really exists.<div onclick> with nice styling A div cannot take focus, so Tab skips it, and its role is generic. Adding role="button" tabindex="0" gets you halfway: Enter and Space stay dead until you write a keyboard handler. <button> gives you all of it for free and CSS can make it look like anything.<button> for navigation (router) Middle-click, Ctrl/Cmd+click and "Open in new tab" only exist on <a href>. Use <a href>, or your router's Link component (React Router, TanStack Router, Next.js), which renders a real <a href>.<a> without href and <div onclick> get skipped: focus() fails on both, even though the <a> says tabIndex 0.<a href> No click. The page scrolls instead: Space only activates buttons, on a link it is the plain scroll key.auxclick or a plain click, no new tab and no link menu.<div role="button" tabindex="0"> work with Enter and Space Press + onkeydown in the table, then prove it with Enter and Space. That is the code <button> gives you for free.