Creating tooltips using the title attribute of HTML
Images have long supported the "alt" attribute, which displays a textual tooltip when the mouse moves over it.
<img src="monster" alt="Big scary monster">
That's fine, and even great, but why should images get all the glory? Shouldn't other elements inside the document be able to carry a tooltip as well, such as a text link or form element? Wouldn't that be pretty cool, not be mention crucial in guiding devises with limited capabilities such as PDAs navigate your site and its various elements? Well, starting in HTML 4, the concept of the "alt" attribute for images have been expanded to all elements on the page.
The title attribute
Here's the idea: HTML 4 supports a "title" attribute that can be inserted inside any HTML tag. Inserting this attribute effectively gives the element a tooltip that pops up when the mouse moves over it. Are you prepared to give a text link a tooltip? Here goes:
The title attribute is supported in all modern web browsers, and can be applied to virtually any element that falls under the <body> tag. Let's see a couple of more examples:
<form> <input type="text" size=25 title="Enter your email address here"> <input type="button" value="Submit"> </form>
Scripting the title attribute
A script is worth a thousand words, so I first illustrate, then explain: