DEV Community

Discussion on: CSS can help improve your HTML⁉ - Ep 2: buttons and links.

Collapse
 
cubiclesocial profile image
cubiclesocial

The problem with using <button>, especially the <input> button types, is that it comes with a LOT of baggage. Safari on iOS, for example, will override styles regardless of what they are with iOS button styles resulting in a less than attractive UI/UX. One could even argue that iOS buttons are downright ugly. a tags, on the other hand, can be styled however the designer wants. But even a tags also have baggage in that preventDefault() has to be called in Javascript (or return false; for the lazy) when handling the click action directly. Failing to do so causes the browser to add # to the URL and push the current page to the browser history back stack.

Collapse
 
grahamthedev profile image
GrahamTheDev

Safari on iOS, for example, will override styles regardless of what they are with iOS button styles resulting in a less than attractive UI/UX

button{
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}
Enter fullscreen mode Exit fullscreen mode

And problem solved there and it has good support.

If this has been stopping you from using a <button> when you should then please start using them now.

Please read this article on why you must use a button as I would hope it will stop you using a pattern we haven't needed for a long time!

Thread Thread
 
code_rabbi profile image
Emeka Orji

😂 I like this guy!

You solved it like "There's your answer, no more excuses"

Thread Thread
 
grahamthedev profile image
GrahamTheDev

Take no prisoners! 🤣