I have to use a submit button to submit one of my forms on a website. Is it possible to use the <button>
element as a submit button? Do I also add the type="submit"
attribute to the <button>
element? i.e.
<button type="submit">Go</button>
Yes, it's possible!
In fact, the <button>
's default behavior is to act as a submit button, so:
<button>Go</button>
Will do what you expect it to! Buttons are also slightly easier to style, and you can keep them consistent with other types of buttons without adding extra rules or selectors in your CSS.
It's worth noting that IE 7 and 6 have some pretty horrible bugs when using <button value="whatever">Something Else</button>
. If you want lower IE compatibility and to use the value=
attribute, don't use <button>