title Attribute


 

Where to use the title Attribute

title is a Common Attribute from the Core Attribute Collection and is of Type Text.

It may be used on most elements in the Element Index - all except: base, head, html, meta, param, script, title.


Description

On Elements Within The Document Body

Almost any element within the body element (including body itself) may be given a descriptive title using the common title attribute. In some user agents this title may appear briefly as a "tooltip" when the mouse hovers over the element.

The title attribute is particularly useful on abbr and acronym elements where it is used to specify the full text for the abbreviation contained within the element. It may also be used on an a element to provide additional information to the user about the link's target URI.

Notes:

  1. Many conventional graphical browsers truncate the content of long title elements within the tooltip so that not all of the title text is visible. However, the tooltip generally disappears after only a short time so there might not be enough time to read long titles anyway.
  2. In any case, some users will not be able to view the contents of title attributes at all (e.g. those users who use purely keyboard navigation in most graphical browsers) so the information within them should not be crucial to the understanding of the page, but instead merely help to elucidate such information as is already present.
  3. Some user agents may render the alt attributes of images in a tooltip by default. Specifying a title should override this behaviour. Specifying an empty string as a title may prevent display of any unwanted alt attribute tooltips.

On Elements Within The Document Head

The only elements within the head element which may be given a title attribute are: link, style and object.

For those link elements which do not link to stylesheets, the title attribute allows the author to provide more information to the user about the content being linked to - in addition to the relationship specified in the rel or rev attribute. (Bear in mind, however, that not all user agents allow link elements to be accessed by the user or, even if they do, they may not display this title information.)

Stylesheets

For link elements which link to stylesheets, the title attribute has additional meaning. It defines a name for the preferred (rel="stylesheet") or alternate (rel="alternate stylesheet") author styles. All stylesheets linked using that particular title should be grouped together by the user agent into a single combined stylesheet. Without any title attribute, the linked stylesheet is a persistent stylesheet, which is always loaded (in addition to the preferred styles or selected alternate styles). Some user agents allow the user to choose between the preferred author styles and the alternate stylesheets specified - if so, it is usually the title attribute for each choice which is presented to the user; informative title text is therefore advised. See the W3C Recommendation *HTML 4.01 - External style sheets for more information.

I cannot currently find it specified anywhere how style elements with title attributes are meant to be treated with respect to persistent, preferred or alternate stylesheets. Without title attributes, however, style elements act as persistent stylesheets.

Not all user agents support alternate stylesheets and, personally, I usually find that sticking with persistent style sheets is all that is required (unless more than one style has been requested). However, if you do want to switch easily between different stylesheets during the development process, alternate stylesheets can be useful (if you're using a browser which supports them, e.g. Firefox).


Page Footer & Copyright

Copyright © Sally Maughan 2005-2009 (Page last updated on 16 May 2009)

*Valid XHTML 1.1 - hosted by *Openstrike

Content based on the W3C Working Draft: *XHTML 1.1 and Recommendation: *XHTML Modularisation 1.1.

W3C, XHTML, XML, HTML, CSS and MathML are *Trademarks of the W3C (*MIT, *ERCIM, *Keio) with which the site's author has no connection.


Up, Next & Previous Links

Your Location

Home > XHTML 1.1 Home > XHTML 1.1 Indexes > Attribute Index (XHTML 1.1) > title Attribute (XHTML 1.1)