Format Code Now
/
Web & markupHTML Image Input Generator Next: HTML Mark Text Generator ›

HTML Image Input Generator

WM-56

Build an input of type image, which is a submit button drawn from a picture, with the alt text it needs.

Runs in your browser. Nothing is uploaded.

Attribute lines: src:, alt:, width:, height:, name:, value:, id:, action:

HTML

How to use it

  1. Write src: with the image address and alt: with what the button does.
  2. Optionally add width:, height:, name:, value: and id: lines.
  3. Keep the form wrapper on and give action: to set where it submits.
  4. Copy the HTML into your page.

This is a button, not an image picker

People often search for an image input when they want to let users choose a picture. That is a file input with accept set to image/*, which the file input generator on this site builds. An input of type image is a graphical submit button: clicking it submits the form, like a button whose face is the picture. Because it is a button, its alt text is its name, and the tool will not generate one without it.

Click coordinates and the alt text

When the user clicks an image button, the browser sends the position of the click inside the image. With a name of go the form data gets go.x and go.y; without a name the fields are x and y. A server can use that for an image map, although most pages ignore it. The alt text should say what the button does, such as Search, and not describe the picture. Keyboard users can press it like any other submit button.

What the tool checks

The src and alt lines are required. Width and height must be whole numbers of 1 or more. A src that begins with javascript: is refused, and every value is escaped before it is written. The picture itself is not loaded or checked, so make sure the address works. For a plain styled button, a button element with CSS is usually simpler, and it lets you include real text.

Error messages and what to do

MessageWhat it meansFix
Missing alt. An image input needs alt text that says what the button does, for example "alt: Search".The input has no alt: line.Add alt: and a short description of what the button does.
Missing src. Add a line such as "src: /img/go.png".The input has no src: line.Add src: and the image address.

Questions people ask

What is input type=image used for?

It is a submit button whose face is an image. Clicking it submits the form and sends the click position. Most modern pages use a button with an icon instead, but the input type still works.

Is input type=image the same as a file input for images?

No. To choose an image file, use input type=file with accept="image/*". The image type is a graphical submit button. Choosing files and submitting a form with a picture button are unrelated jobs, so the two inputs share no attributes beyond the common ones.

Does an image input need alt text?

Yes. The alt text is the button's name for screen readers, so write what the button does, such as Search or Send. This tool refuses to generate one without it.

What are the x and y values the form sends?

The coordinates of the click inside the image, sent as name.x and name.y, or x and y if the input has no name. Servers rarely use them.

Can I use a CSS background instead?

Yes, a button element styled with CSS gives you real text and more control. The image input is still valid when you want a picture as the control.

About this tool

Builds an input of type image, which is a submit button drawn from a picture. It is not a file picker: to let users choose image files, use the file input generator with accept set to image/*. The alt line is required, because it is the button name that screen readers announce. When the button is clicked, browsers send the click position as name.x and name.y (or x and y when there is no name). The src and alt text are escaped, and a src starting with javascript: is refused. The image itself is not loaded or checked here.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.