Note: There is a <title> tag and a title attribute, which are two different things. Tags have angle brackets, while attributes do not.


Attributes: title (images)

HTML images are defined with the <img> tag. The source file (src), alternative text (alt), title text (title) and size (width and height) are provided as attributes.

HTML file: Displayed by browser:
<img src="images/smile.gif" alt="The ALT text" title="The TITLE text" width="42" height="42"> The ALT text
<img src="images/smiley.gif" alt="The ALT text" title="The TITLE text" width="42" height="42"> The ALT text

In the first example, the image filename is mispelled, so the browser cannot find it. When it cannot find an image, it displays the ALT text. In the second example, the image filename is spelled correctly, so the browser displays the image. If you hold the cursor over the image, you will see the TITLE text.



Good habit NEW! In the old days, when the cursor hovered over an image, the alt value popped up in a text box, as well as appeared whenever an image was not found. NOW the alt text appears ONLY when images are not found. The title text displays the popup text box when the cursor hovers over the element. However, screen readers may read out both alt and title, which could be annoying. So it might NOT be wise to use both attributes in the same element.

Back button Table of Contents Next button