8 ms·
Why make it a link if you aren't linking to anything?
by whbrown 2y ago
Why make it a link if you aren't linking to anything?
- andrewfromx 2y agoso you don't have to set "cursor: pointer" in css
- dzaima 2y agoAnd it gives some baseline accessibility functionality. Sucks that there isn't any gerneral "I am clickable" element that neither has bad default click behavior, nor has its own likely-unfitting styling.
- danparsonson 2y agoWhat's wrong with a button? You can make it look like an <a> can't you?
- dzaima 2y agohttps://stackoverflow.com/questions/1367409 https://stackoverflow.com/questions/1367409 has varying amounts of CSS for that, ranging from bad (i.e. more than one line, i.e. the bar to beat for people to automatically use it over <a>) to horrific. Looks like the rough minimum is this: background: none; border: none; padding: 0; cursor: pointer; font: inherit; And, given that some answers there have browser-specific additions, it looks like the spec doesn't have sane effective restrictions on what funky things browsers can do, thus essentially making the answer a "no, you cannot portably make a button look exactly like a link". And no CSS I could find made the button content flow inline with surrounding text (I even went through all of the computed CSS in FF devtools and added the differing ones to the button), so it looks like the answer is "no" in practice too. (though, granted, for a good amount of link-buttons out there you'd probably want no mid-button breaking) Certainly looks like it'd be simpler to make a <span> act like a link, than a <button>, at least. At which point you lose the implicit accessibility functionality.
- deleted 2y ago[deleted]
- KTibow 2y agoYou should really use a button for this. Using anything else is semantically incorrect, and the "it comes with bad styles" argument doesn't make sense given a CSS reset is under 10 lines of code, or even less if you use the `all` style.
- williamdclt 2y agowhy avoid so hard to make it a `submit` for a `<form method="POST" action="/logout">`, which is semantically correct and removes all the need for any javascript (logouts have never needed JS after all)?
- andrewfromx 2y agobecause you often need to send a DELETE verb not POST
- capitantrueno 2y ago"If not link, why link shaped?"