Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialfranckmc
9,095 PointsInput type submit or Button type submit
Hi, everyone
I just saw on MDN that the input tag can have the attribute type set to "submit".
Is there a difference between using the input tag with the attribute type and its value set to submit:
<input type="submit" value="Sign Up">
and the button tag with the attribute type and its value set to submit ?
<button type='submit'>Sign Up</button>
3 Answers
Iain Simmons
Treehouse Moderator 32,305 PointsHi franckmc, here's a useful article on CSS tricks that will hopefully help to answer your question: When To Use The Button Element.
And for the record Liam Maclachlan, you can definitely style the button element with CSS! It can also contain other content/child elements, such as images, which can also be styled.
Dani Ivanov
10,732 PointsI think the input type submit has wider support across browsers as it is an older tag than button.
Have a look at the browser compatibility table over here (near the end of the page)
Input https://developer.mozilla.org/en/docs/Web/HTML/Element/Input
Button https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button
Liam Maclachlan
22,805 PointsPersonally I prefer using the input type. Not only for what Daniel mentions but you can format it to look how you want it to using CSS.
I don't believe that button can be formatted using css :)
Liam Maclachlan
22,805 PointsLiam Maclachlan
22,805 PointsHey man. Thanks for the correction.
Don't know why I thought that but I was definitely wrong on that one :)