html: add a mouse hover “tooltip” to a link.

Here’s a little code snippet you can add to a link so that when someone hovers their mouse over the link, a “tooltip” is displayed, giving them more information. In the example shown below, the image of Dorothy looking out her window is a link to download an audio clip of the theme of the Wicked Witch. The tooltip I added displays the target post’s title “free ringtone: wicked witch of the west” when the mouse hovers over the image.

A simple way to add a tooltip to an image link is to add the following code immediately following the link target:

<span title=”your tooltip language goes here”></span>

For an example of how this was used in the image above, check out the sample code below.
The tooltip code appears highlighted on line 4:

<a href="https://pragmaticcomputing.wordpress.com/
2016/08/24/html-add-a-mouse-hover-tooltip-to-a-link/
wordpress-post-displaytooltiponhover/"> 
<span title="free ringtone: wicked witch of the west">
<img class="alignnone size-large wp-image-685" 
style="border: 1px solid #000000;" 
src="https://pragmaticcomputing.files.wordpress.com/
2016/10/wordpress-post-displaytooltiponhover.png?
w=474" width="474" height="700" /></span></a>

As you might expect, the tooltip code isn’t limited for use with an image link. It can also be used with a text link, again, just by adding it immediately following the link target and before the </a>
(hover over the following text to view the tooltip)

Wicked Witch of the West Theme Song

Here’s what the code from the above text link looks like:

<a href="https://pragmaticcomputing.wordpress.com/
2016/08/24/html-add-a-mouse-hover-tooltip-to-a-link/
wordpress-post-displaytooltiponhover/"> 
<span title="free ringtone: wicked witch of the west">Wicked Witch of the West Theme Song
</a>

To add a tooltip to plain text, it’s even simpler:

<span title=”your tooltip language goes here”>Text to be hovered over.</span>