Testing alternate anchor text

Jon Warbrick
University of Cambridge Computing Service

Its possible to associate additional information with anchors and images (and other things) by using 'alt' and/or 'title' attributes, and/or JavaScript fragments setting window.status. Different browsers do different things with this information, including ignoring some or all of it, displaying it on the status line (commonly at the bottom of the screen), or displaying it in a 'tool-tip' popup. This document contains a 'torture test' that provides examples of most possible combinations and the results for common browsers.

Conclusions

The 'right' way to provide additional information about any part of a document is with the 'title' attribute, and the more modern browsers generally support this usage. The 'alt' attribute is more correctly reserved for providing an alternate version of something for use when the browser can't display the primary version (images and image maps spring to mind). The fact that some browsers display the alt text as a popup when the pointer is over an image, coupled with the HTML 4 requirement that images have alt text, could be seen to be incorrect.

Setting window.status in JavaScript provides an alternative that works for many browsers, including many that don't support the title attribute. In fact a combination of a title attribute and a onmouseover handler setting window.status will provide additional information one way or an other on all tested browsers except Mac Netscape 2.02, which doesn't seem to have any way to do this at all.

You should be sure that the JavaScript handler you use to set window.status returns 'true', otherwise some browsers will ignore your text. Browsers differ in what they do to the status line when the pointer leaves the area. Some set it to blank (or other, browser-dependent, default), others leave the user defined status text in place until it is replaced by other means. Therefore if you don't want your text to continue to be displayed you should set window.status to blank with an onmouseout handler. If on the other hand you do want text to continue to be displayed you will not be able to do this reliably since some browsers unconditionally reset the status line You might be able to use window.defaultstatus to get around this, but I haven't tested this.

Results

Examples of various uses of alt, title, onmouseover and onmouseout attributes appear below. The results observed on various browsers appear against them. The results are coded as follows:

Examples:

S:url/
Status bar displays the url of the link while the pointer is over the area, and nothing (or browser default) once it leaves.
P:title, S:over/out
A popup appears containing the text set by the title attribute, and the status bar displays the text set by the onmouseover handler while the pointer is in the area. The status bar displays the onmouseout handler text when the pointer leaves the area.

Graphical Browsers

  Unix Mac Windows
  NS 4.76 Konqueror 2.1.1 [1] Opera 5.0 NS 2.02 NS 3.04/4.06/4.7 NS 6 IE 4.01/4.5/5.0 NS 4.7 IE 5.0/5.5
Plain anchors                  
no alternative text S:url/ S:url/ S:url/ S:url/ S:url/ S:url/ S:url/ S:url/ S:url/
title S:url/ S:url/ S:title/ S:url/ S:url/ P:title, S:url/ P:title, S:url/ S:url/ P:title, S:url/
mouseover S:over/ S:over/ S:url/over S:over/ S:over/ S:over/ S:over/over S:over/over S:over/over
mouseover mouseout S:over/ S:over/ S:url/out S:over/ S:over/ [2] S:over/ S:over/out S:over/out S:over/out
title mouseover S:over/ S:over/ S:title/over S:over/ S:over/ P:title, S:over/ P:title, S:over/over S:over/over P:title, S:over/over
with title mouseover mouseout S:over/ S:over/ S:title/out S:over/ S:over/ [2] P:title, S:over/ P:title, S:over/out S:over/out P:title, S:over/out
Images                  
no alternative text: nothing nothing S:url/ nothing nothing nothing nothing nothing nothing
alt: Alt text P:alt nothing S:url/ nothing nothing nothing nothing P:alt P:alt
title: nothing P:title S:title/ nothing nothing P:title P:title nothing P:title
mouseover: nothing S:over/over S:over/over nothing nothing S:over/over S:over/over nothing S:over/over
mouseover mouseout: nothing S:over/out S:over/out nothing nothing S:over/out S:over/out nothing S:over/out
alt title: Alt text P:alt P:title S:title/ nothing nothing P:title P:title P:alt P:title
alt tag mouseover: Alt text P:alt S:over/over S:over/over nothing nothing S:over/over S:over/ P:alt P:alt, S:over/over
alt mouseover mouseout: Alt text P:alt S:over/out S:over/out nothing nothing S:over/out S:over/out P:alt P:alt, S:over/out
title mouseover: nothing P:title, S:over/over S:title/over nothing nothing P:title, S:over/over P:title, S:over/over nothing P:title, S:over/over
title mouseover mouseout: nothing P:title, S:over/out S:title/out nothing nothing P:title, S:over/out P:title, S:over/out nothing P:title, S:over/out
alt title mouseover: Alt text P:alt P:title, S:over/over S:title/over nothing nothing P:title, S:over/over P:title, S:over/over P:alt P:title, S:over/over
alt title mouseover mouseout: Alt text P:alt P:title, S:over/out S:title/out nothing nothing P:title, S:over/out P:title, S:over/out P:alt P:title, S:over/out
Images as link: Img alt text P:img alt, S:url/ S:a url/ S:img title S:a url/ S:a url/ P:img title, S:url/ P:img title, S:url/ P:img alt, S:url/ P:img title, S:url
Imagemaps                  
no alternative text: S:url/ S:url/ S:url/ S:url/ S:url/ S:url/ S:url/ S:url/ S:url/
alt: S:alt/ S:url/ S:url/ S:url/ S:url/ S:url/ S:url/ nothing P:alt, S:url/
title: S:url/ S:url/ S:title/ S:url/ S:url/ P:title, S:url/ P:title, S:url/ nothing P:title, S:url/
mouseover: S:over/ S:over/ S:url/over S:url/ S:over/ S:over/ S:over/over S:over/over S:url/
mouseover mouseout: S:over/ S:over/ S:url/out S:url/ S:over/ [2] S:over/ S:over/out S:over/out S:url/
alt title: S:alt/ S:url/ S:title/ S:url/ S:url/ P:title S:url, P:title S:url/ P:title, S:url/ [3]
alt mouseover: S:over/ S:over/ S:url/over S:url/ S:over/ S:over/ S:over/over S:over/over P:alt, S:url/
alt mouseover mouseout: S:over/ S:over/ S:url/out S:url/ S:over/ [2] S:over/ S:over/out S:over/out P:alt, S:url/
title mouseover: S:over/ S:over/ S:title/over S:url/ S:over/ P:title, S:over/ P:title, S:over/over S:over/over P:title, S:url/
title mouseover mouseout: S:over/ S:over/ S:title/out S:url/ S:over/ [2] P:title, S:over/ P:title, S:over/out S:over/out P:title, S:url/
alt title mouseover: S:over/ S:over/ S:title/over S:url/ S:over/ P:title, S:over/ P:title, S:over/over S:over/over P:title, S:url/ [3]
alt title mouseover mouseout: S:over/ S:over/ S:title/out S:url/ S:over/ [2] P:title, S:over/ P:title, S:over/out S:over/out P:title, S:url/ [3]

Text mode browsers

  w3m 0.2.1 lynx 2.8.4dev.7 Emacs W3 4.0
Plain anchors      
no alternative text nothing nothing S:url
title nothing nothing S:title
Images      
no alternative text: D:name D:name [4]
alt: Alt text D:alt D:alt [4]
title: D:name D:title [4]
alt title: Alt text D:alt D:alt [4]
Images as link: Img alt text D:img alt D:img alt [4]
Imagemaps      
no alternative text: D:name, M:url D:name, M:url [4]
alt: D:name, M:alt D:name, M:alt [4]
title: D:name, M:url D:name, M:title [4]
alt title: D:name, M:alt D:name, M:alt [4]

Notes:

[1] Konqueror will occasionally display the 'mouseout' text from a previously tested link the first time the pointer passes over a different link that does not itself have a mouseover handler. This is assumed to be a bug

[2] Mac Netscape 4.06 displays the mouseout text on the status line when the pointer is on the very edge of the active area on the way out, before clearing it.

[3] Despite otherwise appearing to be identical to IE 5.0, IE 5.5 for Windows displays the 'alt' text in a popup if both 'alt' and 'title' are defined.

[4] Display bugs make it difficult to see what is going on here, except that the image itself is displayed. Alt text Alt text Alt text Alt text Alt text Alt text


Jon Warbrick
Last modified: Wed Aug 22 18:31:31 BST 2001