views:

283

answers:

1

This is for an "Add to basket" control for which one of my colleagues has designed a nice graphic. Obviously it should generate a post request, which a simple hyperlink isn't going to do.

Amazon achieves it using an image input. But what are the pros and cons of

<input type="image" src="atb.png" alt="Add to Basket" />

versus

<button type="submit"><img src="atb.png" alt="Add to Basket" /></button>

(and using CSS to control the appearance)?

I guess it boils down to these questions:

  • Do all browsers, graphical and non-graphical, succeed in their duty to make image inputs keyboard-accessible? (Or, in the case of keyboardless devices, make them accessible by whatever the means of input is?)

  • What browsers are there that don't support <button>?

  • What other advantages/disadvantages are there of each?

  • Are there any other possible approaches with their own advantages (besides forgetting it and just using a plain submit)?

+1  A: 

They should be equivalent. For styling purposes, I find button tags are more flexible if you change things in the future.

But: IE has a bug/feature where the value of a button or input is set to equal the innerHTML. This can cause problems if your server side code needs this to be a particular value.

Unless you need the additional styling flexibility of <button> go with <input type="image"> so you don't need to deal with IE's quirks.

edeverett
Side note: The IE bug has been fixed in IE8 Standards Mode.
scunliffe
Yes, I've noticed that IE bug too. We may end up using only one such button per form, IWC this won't be a problem. But I can see the possibility of throwing something into the innerHTML for the server-side code to detect.But `<input type="button">`? Is this a typo, or am I missing something?
Stewart
Yes, it was a typo. Sorry. Fixed.
edeverett