When looking at most sites (including SO), most of them use:
<input type="button" />
instead of:
<button></button>
<button>
come with compatibility issues, seeing it is not very widely used?The <button> tag permits phrasing content inside button element contents like text or images etc, along work with type functionality defined. But the input type=”button” attribute does not permit content.
You use css and style a link <a> to look like a button.
Just as a side note, <button>
will implicitly submit, which can cause problems if you want to use a button in a form without it submitting. Thus, another reason to use <input type="button">
(or <button type="button">
)
Edit - more details
Without a type, button
implicitly receives type of submit
. It does not matter how many submit buttons or inputs there are in the form, any one of them which is explicitly or implicitly typed as submit, when clicked, will submit the form.
There are 3 supported types for a button
submit || "submits the form when clicked (default)" reset || "resets the fields in the form when clicked" button || "clickable, but without any event handler until one is assigned"
<button></button>
)<button></button>
(Hint: IE6)Another IE problem when using <button />
:
And while we're talking about IE, it's got a couple of bugs related to the width of buttons. It'll mysteriously add extra padding when you're trying to add styles, meaning you have to add a tiny hack to get things under control.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With