English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
If the user is unable to view the image for some reason (due to slow connection speed, incorrect src attribute, or the user uses a screen reader), the alt attribute provides alternative information for the image. If the image cannot be displayed, it is necessary to use the alt attribute to specify the alternative text for the image.
Specified alternative text for the image:
<!DOCTYPE html> <html> <head> <title>HTML: <img> alt attribute - Basic Tutorial Website oldtoolbag.com</title> <body> <img src="haha-no.gif" alt="haha face" width="42" height="42"> </body> </html>Test to see ‹/›
IEFirefoxOperaChromeSafari
All mainstream browsers support the alt attribute.
The alt attribute is a required attribute that specifies the alternative text to be displayed when the image cannot be displayed.
If the image cannot be displayed, it is necessary to use the alt attribute to specify the alternative text for the image.
If the user cannot view the image for some reason (due to slow connection speed, incorrect src attribute, or the user is using a screen reader), the alt attribute provides alternative information for the image.
Note:When the user moves the mouse over the img element, Internet Explorer (9 (In previous versions) displaying the value of the alt attribute as a tooltip was incorrect according to the HTML specification.
Tip:If you need to create a tooltip for the image, please use title attribute!
None.
<img alt="text">
value | description |
---|---|
text | Specify the alternative text for the image. Principles of using alt text:
|