I’m am so tired of the never-ending misunderstanding of the alt
attribute versus the title
attribute.
IE’s harm on the world
Internet Explorer up to version 7 incorrectly displays the value of the alt
attribute as a tooltip when you hover an image. This has led to numerous web developers thinking that alt
is supposed to be used for tooltips, and has in turn led to customers, managers et al believing so too, hence incorrectly using the term for when they want a tooltip displayed.
There are still hundreds of thousands of web pages out there built on that the alt
attribute will act as the tooltip. These will only work in Internet Explorer, not in Firefox, Safari, Opera or any other web browser.
The alt
attribute - how it should be
Start by reading the W3C specification:
Several non-textual elements (IMG, AREA, APPLET, and INPUT) let authors specify alternate text to serve as content when the element cannot be rendered normally.
The name of the attribute, alt
, is short for alternate. That means it should be display if the image fails to load, not otherwise.
The true tooltip attribute - title
If you want do display a tooltip, you should instead use the title
attribute. That will work for basically any element in a web page, too, not just image elements.
Microsoft has backed down
With Internet Explorer 8, Microsoft has finally backed down, acknowledged this as a bug, and fixed it. So for anyone depending on the alt
attribute, you need to reconsider, since that will not even work in IE 8.
The difference, once again
The alt
attribute is there as an alternative to the image.
Tooltips, via the title
attribute, is there to complement what you see.
Got it? Please, please say yes!
No comments:
Post a Comment