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 trial

HTML HTML Forms Form Basics The Button Element

Input 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

Hi 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.

Liam Maclachlan
Liam Maclachlan
22,805 Points

Hey man. Thanks for the correction.

Don't know why I thought that but I was definitely wrong on that one :)

Dani Ivanov
Dani Ivanov
10,732 Points

I 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
Liam Maclachlan
22,805 Points

Personally 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 :)