Web HIG tip #3: Links navigate, buttons act #11
frozonfreak
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Web HIG tip #3: Links navigate, buttons act
Most "this button doesn't work" bugs are really a link pretending to be a button, or a button pretending to be a link.
Web HIG tip #3 (Quick #14, #16, #67, #68): Links navigate. Buttons act. Never make navigation behave like an action, and never build controls out of
<div onClick>.Why it matters
Users, browsers, and assistive tech all treat links and buttons differently:
When you mix them up, something quietly breaks:
<button>that callsrouter.push()can't be opened in a new tab or copied<a href="#">that deletes a row adds a junk history entry, and Space scrolls the page instead of firing<div onClick>gets no focus, no keyboard support, and no role, so keyboard and screen-reader users can't use it at allThe rule of thumb
Ask: does this change the URL?
<a href="..."><button type="button">(ortype="submit"inside a form)Styling is separate from semantics. A link can look like a button and a button can look like a link. Pick the element for behavior, then style it.
Do this instead
<a>and<button>before reaching for ARIA roles<div>or<span>for interactive controlshrefso new tab, copy link, and Back all workQuick check for your app
Tab through one screen with the keyboard only. Every control should take focus, show a visible focus ring, and work with Enter (and Space for buttons). Then right-click each "link" and try "Open in new tab". Anything that fails one of those is the wrong element.
The Web HIG is a behavioral contract for how the web should behave, not a component library. Design systems define look. The Web HIG defines behave.
All reactions