←back to thread

Just use a button

(gomakethings.com)
285 points moebrowne | 1 comments | | HN request time: 0.278s | source
Show context
lyricaljoke ◴[] No.45775130[source]
My very similar pet peeve is about websites that use `onclick` handlers and similar to implement navigation. Just use a damn anchor tag, which gets you correct link behavior for free:

* works with middle click for new tab

* integrates with accessibility devices

* works with right click + open in new window or similar options

* etc. etc. etc.

If it's notionally navigation, don't use javascript soup: use a link.

replies(11): >>45775742 #>>45775887 #>>45776191 #>>45776485 #>>45776938 #>>45776972 #>>45777023 #>>45777190 #>>45777640 #>>45779426 #>>45779654 #
1. psygn89 ◴[] No.45776972[source]
Yup. I think a lot of the devs that started with React jumped straight into the "fun" stuff without learning some of the "boring" fundamentals.

And those devs set the wrong patterns and standards for others following hot behind them. The only time I can remember needing to dress a div up like a button was when an accordion trigger was just a giant button and anything passed in would be rendered inside, but I needed an action to the right of the trigger title. But those happen super rarely. You can't just pass in a button as it was invalid html to have nested buttons obviously. Yes, I know I could probably use css to absolutely position it or something but that takes it out of the flow and starts hacking about it in another way.