start page | rating of books | rating of authors | reviews | copyrights

Book HomeHTML & XHTML: The Definitive GuideSearch this book

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.

<head>

Function:

Defines the document header

Attributes:

DIR

LANG

PROFILE

End tag:

</head>; rarely omitted in HTML

Contains:

head_content

Used in:

html_tag

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>.

3.7.1.1. The dir and lang attributes

The dir and lang attributes help extend HTML and XHTML to an international audience. Section 3.6.1.1, "The dir attribute", Section 3.6.1.2, "The lang attribute"

3.7.1.2. 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.

The format of a profile and how it might be used by a browser are not yet defined; this attribute is primarily a placeholder for future development.

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."

<title>

Function:

Defines the document title

Attributes:

DIR

LANG

End tag:

</title>; never omitted

Contains:

plain_text

Used in:

head_content

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

Figure 3-2. What's in a <title>?

3.7.2.1. What's in a title?

Selecting the right title is crucial to defining a document and ensuring that it can be effectively used within the World Wide Web.

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.2.2. The dir and lang attributes

The dir and lang attributes help extend HTML and XHTML to an international audience. Section 3.6.1.1, "The dir attribute", Section 3.6.1.2, "The lang attribute"

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:

<base> and <link>

Define the current document's base location and relationship to other documents. Section 6.7.1, "The <base> Header Element", Section 6.7.2, "The <link> Header Element"

<isindex>

Deprecated in HTML 4, the <isindex> tag at one time could be used to create automatic document indexing forms, allowing users to search databases of information using the current document as a querying tool. Section 6.6.1, "The <isindex> Tag (Deprecated)"

<nextid>

Not supported in HTML 4 or XHTML, the <nextid> tag makes creation of unique document labels easier when using document automation tools. Section 6.8.2, "The <nextid> Header Element"

<meta>

Provides additional document data not supplied by any of the other <head> tags. Section 6.8.1, "The <meta> Header Element"

<object>

Defines methods by which nonstandard objects can be rendered by the browser. Section 12.2.1, "The <object> Tag"

<script>

Defines one or more scripts that can be invoked by elements within the document. Section 12.3.1, "The <script> Tag"

<style>

Lets you create Cascading Style Sheet properties to control body-content display characteristics for the entire document. Section 8.1.2, "Document-Level Style Sheets"



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.