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.
It just seems like a bad word choice.. or am I missing something?
4
The W3C HTML standard on the title
attribute:
This attribute offers advisory information about the element for which it is set…
Values of the title attribute may be rendered by user agents in a variety of ways. For instance, visual browsers frequently display the title as a “tool tip” (a short message that appears when the pointing device pauses over an object). Audio user agents may speak the title information in a similar context. For example, setting the attribute on a link allows user agents (visual and non-visual) to tell users about the nature of the linked resource:
...some text...
Here's a photo of
<A href="http://someplace.com/neatstuff.gif" title="Me scuba diving">
me scuba diving last summer
</A>
...some more text...
The title
attribute is a not a tooltip. It is “advisory information about the element” that particular user agents may choose to render as a tooltip.
The title
attribute is a mechanism to attach a text description directly onto an element; the particular UI implications of this information are implementation-dependent. The only requirement imposed by the WHATWG HTML standard about the visual representation of title
‘s “advisory information” is that the information should be viewable somehow:
User agents should inform the user when elements have advisory information, otherwise the information would not be discoverable.
3
Why? It’s a historical artifact from the early days of the internet. It originated with the HTML 1.2 draft (1993) and was integrated with the HTML 2.0 specification. It’s purpose was to indicate the title of the document–as simple as that.
Deeper dive:
In the beginning, the purpose of HTML was to provide a markup language that could be used for books and documents–not our modern understanding of web pages.
Back in those days, they had this great tag called “Title”
<TITLE> Moby Dick</TITLE>
The purpose of the TITLE tag was to declare the title of the document that you were viewing.
However, when you provided a link, you could add a title to that as well, so that the user knew what the next document was:
<A TITLE="Moby Dick" HREF="...">Next Book</A>
After that point, the title attribute moved to the other tags. Later, when you added a “title” to a picture, the browsers chose not to display that immediately on the webpage, but to add it to the tooltip. As it moved to other elements, it just became the tooltip.
4
I think the tooltip is an implementation decision of browsers, not the intended used expressed in the specification.
I’m inclined to believe that the title attribute was intended for screen readers other and DOM parsers.
There is no good reason for the choice of the attribute name title
. The name has been fixed now, anyway, so the choice is practically irrelevant, except in teaching.
Historically, title
was first defined for links only, and it was seen as specifying an “advisory title” for the linked document – a bit extravagant formulation, which means that it is an external title, i.e. a title (name) of the linked document as provided by the linking document.
Although the title
attribute is still popular in some circles, it is being replaced by “CSS tooltips”, which provide much better rendering and control over it – and do not (normally) use a title
attribute at all.