Archive for the ‘Tasty Tidbits’ Category

Standards-compliant tool-tips

February 17, 2009

I know that everybody in the world but me already knew this, but I finally sorted out what appears to be a workable cross-browser way to do tooltips.

As it turns out, the major browsers display the contents of the “title” attribute as the tool-tip that appears on, for example, anchor tags. It turns out that IE also, and in apparent violation of the standard, uses the value of the “alt” attribute if the title attribute is missing.

For now, until I am convinced to the contrary, I’ll use the “alt” attribute of each img tag to describe the image for text-only browsers. I’ll use the “title” attribute to contain the tooltip contents (limiting it to 75 characters in deference to Firefox behavior).

Advertisements