Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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