Live data from Hacker News

The Difference Between a Button and a Link

unplannedobsolescence.com

51–55 of 55 posts

Re: The Difference Between a Button and a Link

#51
While I understand and perhaps even agree with the semantic argument, the reality of the web is that this will be abused. A sane implementation for a browser would be for an action button with method="get" to get basically all of the affordances a normal link has, e.g. middle click, context menu actions. Sites already exist that hide navigation behind non-links. Now they need to write JS to make that happen, which is at least a bit of a deterrent.

The proposal actually fully treats this as desirable:

> When web authors style links to look like buttons, they inherit the responsibility to make links behave like buttons in all possible contexts.

No, they don't. A web author that works to disable core functionality for links should be fired into the sun, not given easier tools to do so. If your action is really just a navigation, then the user should have the ability to treat it as such.

Re: The Difference Between a Button and a Link

#52

Earlier quoted context omitted.

I stand corrected, thanks for pointing it out. I suppose then I'm back to not seeing the utility of the proposal over form tags.

I guess the distinction would be that in the formaction/formmethod case you'll also submit all the other form data, while the button action will just be an empty body. An extra blank form on the page and the form attribute on the button can work around that, and at that point the argument would basically be: this is super clunky.

But there is no semantically valid reason for the button to be in the form if it doesn't submit the form. So move it outside.

Re: The Difference Between a Button and a Link

#53

You can have button actions today by wrapping the button in a form tag. The article even shows this. The implication seems to be somehow that this is no good because what if you're already in a form tag? The answer is to move the two actions which aren't actually related to the form outside of the form tag and give them their own unique form parents.

What if I want the cancel button to be to the left of the submit button? This is how GitHub lays out those buttons, for instance. There's fundamentally no reason why a button's functionality should be dictated by its position on the page. The proposal has an in-depth explanation of why this and other workarounds (like using the `form` attribute and a bunch of dangling forms) aren't sufficient.[0] [0] https://triptych…

What parent the button has shouldn't have any meaningful limit on how you can style it with modern CSS.

Re: The Difference Between a Button and a Link

#54

If you have a cancel button inside a form, you can point that button to another form dedicated to deleting with the form attribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/... I agree with some of this post but the argument feels muddled. "Clicking a logout button navigates the current page to a logged-out one" is wrong — it changes the state of the session, which is more than just a navigation. "…

Even better, don't put it inside that form. If it isn't submit (or clear) the form then the button has no semantic business being parented by the form.

Re: The Difference Between a Button and a Link

#55

> Copying, sharing, bookmarking—these are all features for re-contextualizing the action of a link. Buttons serve a complimentary purpose because they don’t allow for any of that. This sells me on the opposite of what the author is saying. If, because some jackass decided that to open a page in a different window I need to click the button, copy the URL, then go back and open a new tab, then paste, that's a terrible…

Author addresses almost all your criticism in the material after the first few paragraphs. For example, that government sites enforce accessibility even without js.

None of this is necessary to avoid js, it just means more form tags. Which, frankly, is entirely reasonable if the only thing you're solving for is wanting to avoid links.
Post reply on HN