The alt attribute in HTML provides alternative text for images, aiding accessibility and providing context for screen readers.
Syntax:
<img src=" " alt=" " >
Supported tags:
Name | Description |
---|---|
<area>'s alt provides alternative text for image map areas. | |
<img> alt offers alternative text for image accessibility. | |
specify the alternative text for an image when the image attribute is not displayed. | |
used to specify the alternate text for an applet element. |
Attribute Values:
value | Description |
---|---|
text | is used to specify the alternative text for the supported element if the image is not displaying. |
Example: In This example we includes an image with the alt attribute providing alternative text ("GeeksforGeeks logo") for accessibility.
<!DOCTYPE html>
<html>
<head>
<title>
HTML img alt Attribute
</title>
</head>
<body>
<h1>GeeksforGeeks</h1>
<h2>HTML img alt Attribute</h2>
<img
src=
"https://media.geeksforgeeks.org/wp-content/uploads/20190506164011/logo3.png"
alt="GeeksforGeeks logo">
</body>
</html>