What is the difference between <button> and <input type=“button” />

Place to talk about website HTM elements, CSS style and design, and get help with HTML, CSS codes.
Marius
Posts: 107

What is the difference between <button> and <input type=“button” />

Hi
Which is better to use:

Code: Select all

<input type="button" />
Or:

Code: Select all

<button></button>
What are the main differences between the two, if any?
Are there valid reasons to use one instead of the other?
Are there valid reasons to use combine them?
Does using <button> come with compatibility issues, seeing it is not very widely used?

Admin Posts: 805
Hi
From what i found on the internet.
You can put html into a <BUTTON> tag, for example an image, or other tags, and it is much easier to style using CSS. Buttons can also contain ::before and ::after pseudo-elements.
IE 6 has problems when including multiple <button> into a <form>.
- If you just want a button with a simple text into a form, better use: "<input type="button" />", because <button> will implicitly submit, which can cause problems if you want to use a button in a form without it submitting.
- If you want buttons that aren't into a <form>, for example to be accessed in javascript, use <button>.

Similar Topics