HTML <img> alt Attribute
Example
<img src="img-boy.jpg" alt="Boy" width="300" height="200">
<img src="wrong-image.jpg" alt="wrong image" width="300" height="200">
Meaning
The alt attribute contains a string to be displayed instead of the image for browsers that cannot display images.
Browsers do not always display images. There are a number of situations in which a browser might not display images, such as:
- Non-visual browsers (such as those used by people with visual impairments)
- The user chooses not to display images (saving bandwidth, privacy reasons)
- The image is invalid or an unsupported type
- Slow internet connection
Note: Browsers do not always display images. There are a number of situations in which a browser might not display images.
Standard Syntax
HTML: <img src="URL" alt="text">,
XHTML: <img src="URL" alt="text" />
Advertisement
Attribute Values
| Value | Description |
|---|---|
| text | Specifies an alternate text for an image. |