Images: Alt

The alt attribute specifies an alternate text for an image, if the image cannot be displayed. If a user, for some reason, cannot view an image (because of slow connection, an error in the src attribute, or the user is using a screen reader), then browsers will display alternative information to replace the image:

HTML file: Displayed by browser:
<!DOCTYPE html>
  <html>
    <body>
<p>If a browser cannot find an image, it will display the alternate text:</p>
<img src="wrongname.gif" alt="HTML5 Icon" style="width:128px;height:128px;">
    </body>
  </html>

If a browser cannot find an image, it will display the alternate text:

HTML5 Icon

The alt attribute is required. A web page will not validate correctly without it.

Back button Table of Contents Next button