HTML <img> alt Attribute
HTML <img> tag
Example
An image is marked up as follows:
| <img src="angry.gif" alt="Angry face" /> |
Try it yourself »
|
Definition and Usage
The required alt attribute specifies an alternate text for an image, if the image cannot be displayed.
The alt attribute provides alternative information for an image if a user for some reason cannot view
it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).
Note: Internet Explorer displays the value of the alt attribute as a tooltip when mousing over the img element. This is NOT the correct
behavior, according to the HTML specification. All other browsers are following the specification, and will only display the alt text if the image cannot be displayed.
Tip: If you want to create a tooltip for an image, use the title attribute.
Browser Support

The alt attribute is supported in all major browsers.
Syntax
Attribute Values
| Value |
Description |
| text |
An alternate text for an image. Guidelines for the alt text:
- If the image contains information - use alt to describe the image
- If the image is inside an a element - use alt to explain where the link goes
- If the image is only for decoration - use alt=""
|
HTML <img> tag
Start Creating a stunning, Flash website. It's easy and free!
Wix is a revolutionary web design tool that provides you with a free, simple,
drag & drop editing platform to create your own professional and beautiful website.
Over 2 Million users have created their website with Wix.
Now create yours!
 |
W3Schools' Online Certification Program
The perfect solution for professionals who need to balance work, family, and career building.
More than 4500 certificates already issued!
|
The HTML Certificate documents your knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
|