Attributes: alt

The alt attribute specifies an alternative text to be used, when an HTML element cannot be found. This happens when filenames are misspelled or the file is not uploaded to the website.

HTML file: Displayed by browser:

<img src="nosuch.jpg" alt="alt tooltip" width="104" height="142">

Image filename is mispelled, so browsers cannot find it.

Mozilla Firefox shows:
Google Chrome shows:
Internet Explorer shows:

<img src="w3schools.jpg" alt="alt tooltip" title="title tooltip" width="104" height="142">


Image is found, so browsers have no need for the "alt" text. Move cursor over the image, at the right, to see the title tooltip textbox.

alt tooltip


Good habit Remember: The value of the both the alt and the title attributes may be read by "screen readers" and this could be annoying to anyone "listening" to the webpage (eg. a blind person), hearing it twice. Visually, the alt text only appears in cases of missing elements, and often it is not needed if the image appears. Be very selective as to whether to use the title attribute with the alt attribute!
Back button Table of Contents Next button