+ 3
What is the difference between these two kind of button?
7 Respuestas
+ 10
The differences are subtle.
1. <button> is easier to style with other tags like <em> or <strong> as nested elements.
2. <button type="submit" /> is a newer alternative to <input type="submit" />.
3. If button is the only button within a form tag, it will automatically become the submit button and post the form upon the click event. This can be avoided by explicitly setting the type to "button".
Here are some good links to read for additional differences:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Notes
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/submit
+ 6
Matheus Rodrigues You can use either button for either scenario. I think you might be reflecting what appears to be common usages for these buttons.
+ 4
Calviղ
w3schools still show there's a button attribute 'type', is that because they haven't updated the page?
https://www.w3schools.com/tags/att_button_type.asp
+ 3
Use input type="submit" for form submission, pressing the submit button would trigger onsubmit event of the form element.
It can also used for submitting form to server from form attributes action and method.
+ 2
Button does not have attribute type
<button type="submit">Submit</button> is a wrong syntax.
button would response with onclick attribute usually.
+ 2
the type button is better to use to some animation or interation that you want for the user.
The type submit send a request to url. It’s better to use to send data.