3.7. The Document Header
The document header describes the various properties of the document, including its title, position within the Web, and relationship with other documents. Most of the data contained within the document header is never actually rendered as content visible to the user.
3.7.1. The <head> Tag
The <head> tag serves to encapsulate the other header tags. Place it at the beginning of your document, just after the <html> tag and before the <body> or <frameset> tag. Both the <head> tag and its corresponding ending </head> can be unambiguously inferred by the browser and so can be safely omitted from a document. Nonetheless, we do encourage you to include them in your documents, since they promote readability and support document automation.
The <head> tag may contain a number of other tags that help define and manage the document's content. These include, in any order of appearance: <base>, <isindex>, <link>, <meta>, <nextid>, <object>, <script>, <style>, and <title>.
126.96.36.199. The dir and lang attributes
188.8.131.52. The profile attribute
Often, the header of a document contains a number of <meta> tags used to convey additional information about the document to the browser. In the future, authors may use predefined profiles of standard document metadata to better describe their documents. The profile attribute supplies the URL of the profile associated with the current document.
3.7.2. The <title> Tag
The <title> tag does exactly what you might expect: the words you place inside its start and end tags define the title for your document. (This stuff is pretty much self-explanatory and easier than you might think at first glance.) The title is used by the browser in some special manner, most often placed in the browser window's title bar or on a status line. Usually, too, the title becomes the default name for a link to the document if the document is added to a link collection or to a user's "hot list."
The <title> tag is the only thing required within the <head> tag. Since the <head> tag itself and even the <html> tag may be safely omitted, the <title> tag could be the first line within a valid HTML document. Beyond that, most browsers will even supply a generic title for documents lacking a <title> tag, such as the document's filename, so you don't even have to supply a title. That goes a bit too far even for our down-and-dirty tastes. No respectable author should serve up a document missing the <title> tag and a title.
Browsers do not specially format title text and ignore anything other than text inside the title start and end tags. For instance, they will ignore any images or links to other documents.
Here's an even barer barebones example of a valid HTML document to highlight the header and title tags; watch what happens when Netscape displays it in Figure 3-2:
<html> <head> <title>HTML and XHTML: The Definitive Guide</title> </head> </html>
Figure 3-2. What's in a <title>?
184.108.40.206. What's in a title?
Keep in mind that users can access each of your documents in a collection in nearly any order and independently of one another. Each document's title should therefore define the document both within the context of your other documents as well as on its own merits.
Titles that include references to document sequencing are usually inappropriate. Simple titles, like "Chapter 2" or "Part VI" do little to help a user understand what the document might contain. More descriptive titles, such as "Chapter 2: Advanced Square Dancing" or "Part VI: Churchill's Youth and Adulthood," convey both a sense of place within a larger set of documents and specific content that invites the reader to read on.
Self-referential titles also aren't very useful. A title like "My Home Page" is completely content-free, as are titles like "Feedback Page" or "Popular Links." You want a title to convey a sense of content and purpose so that users can decide, based upon the title alone, whether to visit that page or not. "The Kumquat Lover's Home Page" is descriptive and likely to draw in lovers of the bitter fruit, as are "Kumquat Lover's Feedback Page" and "Popular Links Frequented by Kumquat Lovers."
People spend a great deal of time creating documents for the Web, often only to squander that effort with an uninviting, ineffective title. As special software that automatically collects links for users becomes more prevalent on the Web, the only descriptive phrase associated with your pages when they are inserted into some vast link database will be the title you choose for them. We can't emphasize this enough: take care to select descriptive, useful, context-independent titles for each of your documents.
3.7.3. Related Header Tags
Other tags you may include within the <head> tag deal with specific aspects of document creation, management, linking, automation, or layout. That's why we only mention them here and describe them in greater detail in other, more appropriate sections and chapters of this book.
Briefly, the special header tags are:
Copyright © 2002 O'Reilly & Associates. All rights reserved.