What is the purpose of the "Image" input?

Asked

Viewed 338 times

10

Only now have I realized these days that there is one input with the attribute type equal to "image".

I saw this being used on some site (very old by the way) to submit a form.

I have the following doubts:

  • What is the purpose of this input[type=image]?
  • It only serves to make form submission?
  • This attribute should be avoided, or can still be used quietly (we are in 2017 only to state the date)?

Reference: MDN - Input Type Image

1 answer

8


Stylization

The most obvious reason is to make a more "cute" commit button using an image instead of the default button. It has become unnecessary since HTML5 since all document objects can be stylized in other ways.

And it doesn’t even work the same as what is expected of a button in all situations (it may not send the value of the button but the coordinates from where it was clicked that is not relevant in almost all cases and takes out possible information that matters), so avoid it. Prefer the button who does what he must do.

This was created kind of by sneaking around to solve a problem without thinking at all.

Mapped image

There is another slightly better reason that is to map image. The form with this tag send the coordinates of the click given in the image and this may help to make a decision. There are cases where the position you gave the click determine the action.

It is possible map images only on the page. When you use this in the form indicates that you want the data to be sent to the form is the click. Example. Documentation ("Using the x and y data points"). Tool to help mapping.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.