Приглашаем посетить
Просвещение (lit-prosv.niv.ru)

3.7 The Document Header

Table of Contents

  Previous   Next

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 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> tag can be unambiguously inferred by the browser and so can be safely omitted from an HTML, but not an XHTML, document. We encourage you to include them in all your documents, since they promote readability and support document automation.

<head>

Function

Defines the document header

Attributes

dirlangprofile

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

As we discussed in the sections about the <html> tag attributes, dir and lang help extend HTML and XHTML to an international audience. [Section 3.6.1.1] [Section 3.6.1.2]

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 favorites or bookmarks list.

<title>

Function

Defines the document title

Attributes

dirlang

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 can safely be 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, though. No respectable author should serve up a document missing the <title> tag and a title.

Browsers do not specially format title text, and they 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>?
figs/htm5_0302.gif
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 on the Web.

Keep in mind that users can access each of the documents in your 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 and 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 "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 phrases associated with your pages when they are inserted into some vast link database will be the titles 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] [Section 3.6.1.2]

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. [<base>] [<link>]

<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. [<isindex>]

<nextid>

Not supported in HTML 4 or XHTML, the <nextid> tag tried to make creation of unique labels easier when using document automation tools. [<nextid>]

<meta>

Provides additional document data not supplied by any of the other <head> tags. [<meta>]

<object>

Defines methods by which nonstandard objects can be rendered by the browser. [Section 12.2.1]

<script>

Defines one or more scripts that can be invoked by elements within the document. [Section 12.3.1]

<style>

Lets you create CSS properties to control body-content display characteristics for the entire document. [<style>]

    Table of Contents

      Previous   Next