Alt and Title Attributes for Images

The alt attribute on the image tag as in ...

<image src="sunset.jpg" alt="nice sunset" />

specifies the text that is displayed whenever the image is not-displayable.

But one difference between Internet Explorer and Firefox is in the case when the image is displayable. For Internet Explorer, the text in the alt text also comes up as a tooltip when the user hovers the mouse over the image. In Firefox, this does not happen. And as per the W3C specification, it should not happen.

Nevertheless, there are some people who want the tooltip display of the alt text for both browser. To get Firefox to display a tooltip text for an image, you would use the title tag instead, which is the designed intent of the title tag.

So if you want tooltip to appear when user hovers over images regardless of whether they are using IE or Firefox, then you would use both the alt and title attribute of the image tag as in ...

<image src="sunset.jpg" alt="nice sunset" title="nice sunset" />