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 i
From MDN:
When you submit a form using a button created with
<input type="image">
, two extra data points are submitted to the server automatically by the browser — x and y.
So one difference is that the input[type=image]
transmits the coordinates of the pixel you clicked. It is 2019 and button
is well supported so personally I use it unless I really need x, y
- lets say, if the image is a map and I want to know where the user clicked in the map.
Input type="Image" supports the Disabled attribute and the browser will Grey out the image for you. With Type=Button you'd have to provide an alternate grey image.
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.