English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

Complete list of HTML tags

HTML: <input> alt attribute

The input alt attribute provides alternative text for users if the image cannot be viewed due to some reason (slow connection, src attribute error, or the user is using a screen reader). The alt attribute can only be used with <input type=image>.

 HTML <input> tag

Online example

HTML form, submit uses an image as the "submit" button:

<!DOCTYPE html>
<html>
<head>
<title>HTML:<input> alt attribute - 基础教程网(oldtoolbag.com)</title>
<body>
<form action="action_page.php">
  First name: <input type="text" name="fname"><br>
  <input type="image" src="submit.gif" alt="Submit" width="48" height="48">
</form>
<p>Click on the image, the input will be sent to the page named "action_page.php" on the server.</p>
<p>Notice: The default behavior of the image input type is to activate the X and Y coordinates of the click on the image button.</p>
</body>
</html>
Test it out ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the alt attribute.

Definition and Usage

If for some reason (due to slow connection, src attribute error, or user using a screen reader) the image cannot be viewed, the alt attribute provides the user with alternative text.
Note: The alt attribute can only be used with<input type ="image">.

HTML 4.01 with HTML5differences

None.

Syntax

<input alt="text">

Attribute value

ValueDescription
textSpecifies alternative text for an image.
 HTML <input> tag