←back to thread

Just use a button

(gomakethings.com)
285 points moebrowne | 1 comments | | HN request time: 0.254s | source
Show context
pverheggen ◴[] No.45774978[source]
A good addition to this article is that most buttons should have type="button" on them. By default, buttons are type="submit", which if contained inside a form will submit that form.

I'm sure there are some devs who reach for a div because they're unaware of the proper way to disable submit behavior.

replies(4): >>45775148 #>>45775591 #>>45775683 #>>45775964 #
mixmastamyk ◴[] No.45775683[source]
Believe that default is for <input type="submit">, not <button>.
replies(3): >>45775737 #>>45775922 #>>45776810 #
tomkarho ◴[] No.45776810[source]
I seem to recall that once upon a time the default type for a button was in fact "button" but at some point (somewhere in the region of html 5 / es6) it was switched into "submit".
replies(1): >>45781018 #
1. pwdisswordfishy ◴[] No.45781018[source]
The nice thing about actually versioning standards (instead of doing that lazy "living standard" shit) is that you can actually look such things up.

https://www.w3.org/TR/html4/interact/forms.html#adef-type-BU...