This Wiki page is edited by participants of the WCAG Working Group. It does not necessarily represent consensus and it may have incorrect information or information that is not supported by other Working Group participants, WAI, or W3C. It may also have some very useful information.
Techniques/HTML/Providing a title using the title element
From WCAG WG
H25: Providing a title using the title element
(@@@ Chris - opening suggestion - merge this and G88 into one General ST - very much duplicate info)
HTML4, HTML5 and XHTML @@@ Chris - added HTML 4 and 5 disambiguation
This technique relates to:
- Success Criterion 2.4.2 (Page Titled)
All HTML and XHTML documents, including those in individual frames in a frameset, have a title element in the head section that defines in a simple phrase the purpose of the document. This helps users to orient themselves within the site quickly without having to search for orientation information in the body of the page.
(@@@ Chris - When reviewing this, I found that this doesn't really make sense, but I've always been a little uncomfortable with 2.4.2 since I'm a metadata person in my other life (but I'm not suggesting we rewrite 2.4.2 mind you). The true reason for the title attribute is to provide context rich information to users before they open a document - it always has been a metadata element. As metadata, UA/AT has no obligation to render the content of the title element anywhere, and many of the examples in the Understanding document really talk about a "title" as it appears in a link within a site, which has nothing to do with the Title element, although external to a site it has become a SEO tool. Suggest rewrite to indicate context-rich, understandable titles as per spec (eg: HTML 4: "Since users often consult documents out of context, authors should provide context-rich titles") and not key word spam etc. The accessibility linkage in that sense is in the 3.1 context as much as 2.4.2. I think this clarification is important within the HTML5 context given the reliance the semantic web and linked data has on metadata, and the rise of accessibility metadata standards such as A4A (Access for All) in the Dublin Core community as well as the benefits semweb and linked data bring to the accessibility table.)
Note that the (mandatory) title element, which only appears once in a document, is different from the title attribute, which may be applied to almost every HTML and XHTML element. (@@@ Chris - why is mandatory in brackets. It is for all but transitional HTML 4 - should just call it mandatory and be done with it here.)
Examples of successful application of the Technique
This example defines a document's title. Note: in all applicable languages, the title element can only be used as a child of the head element in a document. @@@ Chris - added element usage note to assist authors.
Example Code - all applicable languages: @@@ Chris - removed name space declaration so example could be used cross language.
...> <head> <title>The World Wide Web Consortium</title> </head> <body> ... </body>
Resources are for information purposes only, no endorsement implied.
- G88: Providing descriptive titles for Web pages
- G127: Identifying a Web page's relationship to a larger collection of Web pages
- Examine the source code of the HTML or XHTML document and check that a non-empty title element appears in the head section.
- Check that the title element describes the document.
- Checks 1 and 2 are true.
If this is a sufficient technique for a success criterion, failing this test procedure does not necessarily mean that the success criterion has not been satisfied in some other way, only that this technique has not been successfully implemented and can not be used to claim conformance. (@@@ Actually in this case, this isn't true - you fail this one, you pretty much fail 2.4.2 full stop. And you have non-validating code if you fail 1, and breach the "should" requirement of the spec as well as fail 3.1 IMO - suggest this boilerplate be amended)