What with weblogs being all about links, you would think more people would know about the title attribute, but I rarely see it. For those who don’t know, all links can have a title, specified by the title attribute of the <a> tag. This is in addition to whatever link text you specify. The title of a link generally shows up as a tooltip in visual browsers, but it can be presented in non-visual browsers as well.
Not all links should have titles. If the link text is the name of an article, don’t add a title; the link text itself is descriptive enough. But if you read the link text by itself, out of context, and can’t figure out what it points to, add a title.
On each link where the link text itself might not be sufficient for the reader to decide whether to click the link, add a title attribute. Examples:
On my navigation bar, I have a link to my statistics page. The link text is simply Statistics, but the title attribute gives some further information:
<a title="referrers and other visitor statistics" href="/stats/">Statistics</a>
On my navigation bar, I have a link to my book, Dive Into Python, which looks like this:
<a title="Free Python book for experienced programmers" href="http://diveintopython.org/">Dive Into Python</a>
When I link to an article using a phrase within a sentence, I try to use a title attribute to give identifying information about the link, such as the article title or a citation. For instance, yesterday’s tip included this sentence:
Why is this a problem? Because <a title="TheCounter.com statistics on Javascript usage in browsers, April 2002" href="http://www.thecounter.com/stats/2002/April/javas.php">11% of Internet users don't use Javascript</a> for one reason or another, including many disabled users whose browsers simply don't support it.
Which renders like this:
Why is this a problem? Because 11% of Internet users don’t use Javascript for one reason or another, including many disabled users whose browsers simply don’t support it.
Do not go overboard with the title attribute. All things in moderation.
§
I am no longer accepting public comments on this post, but you can use this form to contact me privately. (Your message will not be published.)
§
firehose ‧ code ‧ music ‧ planet
© 2001–8 Mark Pilgrim