home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeHTML & XHTML: The Definitive GuideSearch this book

6.7. Relationships

Very few documents stand alone. Instead, a document is usually part of a collection of documents, each connected by one or several of the hypertext strands we describe in this chapter. One document may be a part of several collections, linking to some documents and being linked to by others. Readers move between the document families as they follow the links that interest them.

You establish an explicit relationship between two documents when you link them. Conscientious authors use the rel attribute of the <a> tag to indicate the nature of the link. In addition, two other tags may be used within a document to further clarify the location and relationship of a document within a document family. These tags, <base> and <link>, are placed within the body of the <head> tag. Section 3.7.1, "The <head> Tag"

6.7.1. The <base> Header Element

As we previously explained, URLs within a document can be either absolute (with every element of the URL explicitly provided by the author) or relative (with certain elements of the URL omitted and supplied by the browser). Normally, the browser fills in the blanks of a relative URL by drawing the missing pieces from the URL of the current document. You can change that with the <base> tag.

<base>

Function:

Define the base URL for other anchors in the document

Attributes:

HREF

TARGET

End tag:

None in HTML; </base> or <base ... /> with XHTML

Contains:

Nothing

Used in:

head_content

The <base> tag should appear only in the document header, not its body contents. The browser thereafter uses the specified base URL, not the current document's URL, to resolve all relative URLs, including those found in <a>, <img>, <link>, and <form> tags. It also defines the URL that will be used to resolve queries in searchable documents containing the <isindex> tag. Section 6.2, "Referencing Documents: The URL"

6.7.1.2. The target attribute

When working with documents inside frames, the target attribute with the <a> tag ensures that a referenced URL gets loaded into the correct frame. Similarly, the target attribute for the <base> tag lets you establish the default name of one of the frames or windows in which the browser is to display redirected hyperlinked documents. Section 11.1, "An Overview of Frames"

If you have no other default target for your hyperlinks within your frames, you may want to consider using <base target=_top>. This ensures that links that are not specifically targeted to a frame or window will thereby load in the top-level browser window. This eliminates the embarrassing and common error of having references to pages on other sites appear within a frame on your pages, instead of within their own pages. A minor bit of HTML, to be sure, but it makes life much easier for your readership.

6.7.2. The <link> Header Element

Use the <link> tag to define the relationship between the current document and another in a Web collection.

<link>

Function:

Define a relationship between this document and another document

Attributes:

CHARSET

ONKEYUP

CLASS

ONMOUSEDOWN

DIR

ONMOUSEMOVE

HREF

ONMOUSEOUT

HREFLANG

ONMOUSEOVER

ID

ONMOUSEUP

LANG

REL

MEDIA

REV

ONCLICK

STYLE

ONDBLCLICK

TARGET

ONKEYDOWN

TITLE

ONKEYPRESS

TYPE

End tag:

None in HTML; </link> or <link ... /> with XHTML

Contains:

Nothing

Used in:

head_content

The <link> tag belongs in the <head> content, nowhere else. The attributes of the <link> tag are used like those of the <a> tag, but their effects serve only to document the relationship between documents. The <link> tag has no content and only XHTML supports the closing </link> tag.

6.7.2.6. Other <link> attributes

The HTML 4 and XHTML standards also include the ubiquitous collection of attributes related to style sheets and user events, and language for the <link> tag. You can refer to the corresponding section describing these attributes for the <a> tag for a complete description of their usage. Section 6.3.1, "The <a> Tag"

Since you put the <link> tag in the <head> section, whose contents do not get displayed, it may seem that these attributes are useless. It is entirely possible that some future browser may find some way to display the <link> information to the user, possibly as a navigation bar or a set of hot-list selections. In those cases, the display and rendering information would prove useful. Currently, no browser provides these capabilities.



Library Navigation Links

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