<button>
tags are more easily stylable than inputs, and I'm really in favor of using them. However I'm afraid some problems may arise.
From W3schools: Note: If you use the <button> element in an HTML form, different browsers may submit different values. Use <input> to create buttons in an HTML form.
I also read that IE has problems with this buttons. I'm only looking to use them as a replace for submit buttons, eg:
<form>
<input type="text" name="post"/>
<button type="submit">
</form>
Will they work the same as submit buttons or will I have problems like unsupported browsers or anything else?
The button
element has had serious problems with IE, which used to have a very broken implementation. This still remains a concern. According to MDN page on button
, IE 7 is still very broken in this respect, sending wrong data upon submission.
But if your form handling does not depend on the name=value data that results from a button
element, button type=submit
is safe these days. For example, when you have only one such button in the form, you probably wouldn’t use the name=value pair for anything anyway.
I haven't experienced any IE problems with a <button type="submit">
, and at the very very worse, you can always attach an onclick
event handler to it.
A <button>
should be safe to use.
As a final note: w3schools is a wrong and misleading site. You shouldn't use it as reference for any sort of language. For PHP, there's the PHP Manual, for JavaScript, there's Mozilla Developer Network (or MDN). See http://w3fools.com to further understand why you should never use w3schools.
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