HTML img tag: title attribute vs. alt attribute?
alt and title are for different things, as already mentioned. While the title attribute will provide a tooltip, alt is also an important attribute, since it specifies text to be displayed if the image can't be displayed. (And in some browsers, such as firefox, you'll also see this text while the image loads)
Another point that I feel should be made is that the alt attribute is required to validate as an XHTML document, whereas the title attribute is just an "extra option," as it were.
They are used for different things. The alt
attribute is used instead of the image. If the image can't be shown, and in screen readers.
The title
attribute is shown along with the image, typically as a hover tooltip.
One should not be used "instead" of the other. Each should be used properly, to do the things they were designed to do.
I'd go for both. Title will show a nice tooltip in all browsers and alt will give a description when browsing in a browser with no images.
That said, I'd love to see some stats of how many "surfers" out there going to a "store" to browse merchandise actually have images turned off or are using a browser that doesn't support images. I think the days where 90% of the population is using a 28k modem to connect to the InterWeb is looooong over.