by mr-wendel on 4/9/21, 5:54 PM
The problem is that links provide a very reliable way to perform a controlled HTTP request to get a dynamic response from the backend.... without using JavaScript. I love JavaScript, but if device reusability is a serious concern then JavaScript is the elephant in the room, not this topic. Is it available? What version is supported? What quirks does the engine have? To be fair... it was posted in 2013 :D.
The only working alternative (editing if I stand corrected!) using buttons is to make them form buttons. Now otherwise intuitive behaviors (e.g. forward/back, refresh) are laden with "you're about to resend data!" warnings that completely break the flow.
To me, it makes perfect sense why this trend evolved. Most people agree with the underlying premise about user expectation on button vs link. Dressing links up as button is a direct response to that. I understand the technical arguments, but users care what it looks like and how it behaves, not how you implemented it.
Edits:
- Yes, you can use <form method="get"...> without scary browser warnings. It just gets a but ugly if you have lots of buttons, as each needs its own form wrapper.
- 303 redirects to POST request are a handy pattern to be aware of no matter what :)
by superkuh on 4/9/21, 5:37 PM
Everything is a button now that javascript applications have replaced HTML documents. And there are no such things as anchors or links anymore. They are not URLs but instead triggers for more javascript execution. We're, unfortunately, well past this minor problem and onto much more serious ones that eclipse it.
by lights0123 on 4/9/21, 9:33 PM
And never use href="#" or href="javascript:void(0)": middle-clicking on it will lead to unexpected results.
I'm looking at you, Hacker News
by _greim_ on 4/9/21, 9:21 PM
I think the converse—buttons are not links—doesn't get enough attention. The litmus test is that if clicking it is supposed to navigate, you should also be able to shift+click or middle-click to open it in a new tab, or drag it up to your toolbar to make a bookmark.
by lfowles on 4/9/21, 5:52 PM
One pet peeve of mine with the button-ish links is that sometimes they only work if I click on the text itself.
by eximius on 4/9/21, 6:31 PM
Buttons do something.
Links go somewhere.
Don't cross the streams.
by paxys on 4/9/21, 8:14 PM
I think 90% of the misuse arises from devs not realizing that they can use a <button> or <a> (or whatever else is correct in that context) and still style it however they want.
by dheera on 4/9/21, 5:55 PM
Big pet peeve: Web apps where some buttons look like buttons and some buttons look like links. Everything that initiates an action of some sort should look the same, damnit.
by adsfasdfdsfg on 4/10/21, 2:24 AM
Historically, styling buttons wasn't supported. The result of styling an input element of type submit and a button element were different too. It eroded adherence to proper semantics. I think people are still used to the workaround which is use an anchor element.
by tootie on 4/9/21, 8:06 PM
His main points are about accessibility but there's a lot of overlap between accessibility and SEO. Google needs semantic tags to understand your site. It will treat any <a> as navigation and won't do the same for <button> or any other approach. The basic premise that <button> is for CTAs and <a> is for navigation is the golden rule. You can style either anyway that you want.
by ironmagma on 4/9/21, 8:07 PM
Honestly, if you spend energy worrying about this issue, it's like using a bucket to bail water out of a sinking cruise ship.
by blackbrokkoli on 4/9/21, 6:30 PM
I agree with the author...partly.
Sure, <divs> and <spans> are not buttons and should not ever be used as those. Knowing and adhering to standards, especially when they are there for accessibility, is an excellent thing.
But in some cases, making links links instead of buttons (and similar scenarios) just means exposing internal works to the user. Say I have a SaaS with the classic "GET STARTED NOW" button on the landing page. Now I change my tech stack from something classic like Rails or Lavarel, where "get started" probably means a link to the signup page to some fancy JavaScript which triggers the action of overlaying a signup form. Would you really agree that the HTML for my "GET STARTED NOW" button should change depending on what kind of method my app uses?