[_] <button></button> or <input type="button" />?
Tim Beadle
tim.beadle at gmail.com
Tue Jun 24 16:54:26 BST 2008
On Tue, Jun 24, 2008 at 4:37 PM, speed wolf <speedwolf at gmail.com> wrote: > I know that <button> is the more recent of the two options, but does that > necessarily make it the right choice? > > Obviously it's the more semantically correct of the two but input with a > type of button is in greater use on the web at large. > Comments and advice would be greatly appreciated. It depends - what are you trying to do? >From the Sitepoint HTML Reference... "button" This is a simple clickable button that doesn't actually do anything per se (unlike a Submit button, which sends the form data to the location defined in action). The input button type is usually used along with JavaScript to trigger some kind of behavior (for example, using a button to open a help page in a new window). -- http://reference.sitepoint.com/html/input/type I'm pretty keen on progressive enhancement: I believe that stuff should work without Javascript being enabled; you then hijack events with Javascript (like the click event on a link) and layer more advanced functionality on top. Ergo <input type="button">, being useless without Javascript, is a no-no. The <button> element, on the other hand, can take type="submit" so can submit a form in the normal way and be Progressively Enhanced just like <input type="submit">, which is your other choice and works just fine. Cheers, Tim