The HTML <input> alt attribute provides alternative text for an image used in an input element. It is mainly used with type="image" to display text if the image cannot be loaded.
- Provides alternative text for image input elements and improves accessibility.
- Mainly used with <input type="image"> elements.
- Displays descriptive text when the image cannot be loaded.
Syntax:
<input type="image" src="https://www.geeksforgeeks.org/submit.png" alt="Submit Button">Attribute Values: It contains single value text which is used to specify the alternative text for input if the image is not displaying.
<!DOCTYPE html>
<html>
<head>
<title>
HTML Input alt Attribute
</title>
</head>
<body style="text-align:center;">
<h1 style="color:green;">
GeeksForGeeks
</h1>
<h2>HTML Input alt Attribute</h2>
<input id="myImage"
type="image"
src=
"https://media.geeksforgeeks.org/wp-content/uploads/gfg-40.png"
alt="Submit"
width="48"
height="48">
</body>
</html>