HTML <img> altAttribute
Example
Image with specified alternative text:
Try it Yourself »
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the alt attribute.
Definition and Usage
The alt attribute is a required attribute that specifies alternative text when the image cannot be displayed.
Suppose for some reason (such as slow network speed, an error in the src attribute, the browser disabling images, or the user using a screen reader) the user cannot view the image, the alt attribute can provide alternative information for the image.
Note:When the user moves the mouse over the img element, Internet Explorer (versions before 9) displays the value of the alt attribute as a tooltip. According to the HTML specification, this behavior is not correct.
Tip:If you need to create a tooltip for an image, use thetitleattribute!
Differences between HTML 4.01 and HTML5
None.
Syntax
Attribute Values
| Value | Description |
|---|---|
| text | Specifies the alternative text for the image. Principles for using alt text:
|
HTML <img> Tag Other Extensions