Image submit input (type="image")
HTML Living Standard
Use an image as a submit control. Give it alt text that describes the action.
On this page
Attributes and behavior
| Value or syntax | What it does |
|---|---|
src / alt | Provide the image source and an accessible name for the action. |
name="send" | A named image submits click coordinates as send.x and send.y. |
Try the example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Image submit input</title>
<style>
form { display: grid; gap: 12px; justify-items: start; } output { display: block; margin-top: 10px; }
</style>
</head>
<body>
<form id="demo">
<input type="image" name="send" alt="Send selection" width="44" height="44" src="data:image/svg+xml,%3Csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20viewBox=%270%200%2044%2044%27%3E%3Crect%20width=%2744%27%20height=%2744%27%20rx=%276%27%20fill=%27teal%27/%3E%3Cpath%20d=%27M10%2022h22m-8-8%208%208-8%208%27%20fill=%27none%27%20stroke=%27white%27%20stroke-width=%273%27/%3E%3C/svg%3E">
<button type="submit">Check</button>
</form>
<output id="response"></output>
<script>
const form = document.querySelector('#demo');
form.addEventListener('click', event => {
const submitter = event.target.closest('[type="submit"], [type="image"]');
if (!submitter) return;
event.preventDefault();
if (!form.noValidate && !submitter.formNoValidate && !form.reportValidity()) return;
const values = new FormData(form, submitter);
document.querySelector('#response').textContent =
'Passed validation. Fields received: ' + [...values.keys()].join(', ');
});
</script>
</body>
</html>
What to expect Click the arrow. The output lists coordinate fields.