HTML <input> alt attribute
Definition and Usage
alt
The attribute provides alternative text for the user if they cannot view the image for some reason (due to slow connection speed, an error in the src attribute, or if the user is using a screen reader).
Note:alt
The attribute can only be associated with <input type="image"> used together.
Note:even alt
The attribute is not a required attribute, but it should still be set when the input type is image. If this attribute is not used, it may cause usability issues for text browsers or non-visual browsers.
Example
HTML form with an image representing a submit button:
<form action="/action_page.php"> <label for="fname">Name:</label> <input type="text" id="fname" name="fname"> <input type="image" src="submit.gif" alt="Submit" width="48" height="48"> </form>
Syntax
<input alt="text">
Attribute Value
Value | Description |
---|---|
text | Specify the alternative text for an image. |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |