HTML The Definitive Guide (79 page)

Read HTML The Definitive Guide Online

Authors: Chuck Musciano Bill Kennedy

BOOK: HTML The Definitive Guide
4.86Mb size Format: txt, pdf, ePub

attribute, 3.5.1.2]

7.6.1.5 Server dependencies

Like image maps, searchable documents require support from the server to make things work. How the server interprets the query URL and its parameters is not defined by the HTML standard.

You should consult your server's documentation to determine how you can receive and use the search parameters to locate the desired document. Typically, the server breaks the parameters out of the query URL and passes them to a program designated by the URL.

7.5 Mouse-Sensitive Images

7.7 Establishing Document

Relationships

Chapter 7

Links and Webs

 

7.7 Establishing Document Relationships
Very few HTML documents stand alone. Instead, a document is usually part of a collection of documents, each connected by the 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 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, and , are placed within the body of the
tag. [, 3.6]

7.7.1 The 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 tag.


Function:

Define the base URL for other anchors in the document Attributes:

HREF

TARGET

End tag:

None

Contains:

Nothing

Used in:

head_content

The tag must 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 , , , and

tags. It also defines the URL that will be used to resolve queries in searchable documents containing the tag.
[Referencing

Documents: The URL, 7.2]

7.7.1.1 The href attribute

The href attribute must have a valid URL as its value, which the browser then uses to define the absolute URL against which relative URLs are based within the document. For example, the tag in this document head:




...

tells the browser that any relative URLs within this document are relative to the top-level document directory on
www.kumquat.com
, regardless of the address and directory of the machine from which the user had retrieved the current document.

Contrary to what you may expect, you can make the base URL relative, not absolute. The browser actually forms an absolute base URL out of this relative URL by filling in the missing pieces with the URL of the document itself. This property can be used to good advantage. For instance, in this next example:




...

the browser will make the URL into one that is relative to the server's
info
directory, which probably is not the same directory of the current document. Imagine if you had to re-address every link in your document with that common directory. Not only does the tag help you shorten those URLs in your document that have a common root, it also lets you constrain the directory from which relative references are retrieved without binding the document to a specific server.

7.7.1.2 The target attribute

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

If you have no other default target for your hyperlinks within your frames, you may want to consider using . This will ensure 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.

7.7.1.3 Using

The most important reason for using is to ensure that any relative URLs within the document will resolve into a correct document address, even if the document itself is moved or renamed. This is particularly important when creating a document collection. By placing the correct tag in each document, you can move the entire collection between directories and even servers without breaking all of the links within the documents.

You also need to use the tag for a searchable document () if you want user queries posed to a URL different from the host document.

Note that a document that contains both the tag and other relative URLs may have problems if the relative URLs are not relative to the desired index-processing URL. Since this is usually the case, do not use relative URLs in searchable documents that use the tag to specify the query URL for the document.

7.7.2 The Header Element

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


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

Contains:

Nothing

Used in:

head_content

The tags belongs in the content, nowhere else. The attributes of the tag are used like those of the tag, but their effects serve only to document the relationship between documents. The tag has no content and no closing element.

7.7.2.1 The href attribute

As with its other tag applications, the href attribute specifies the URL of the target tag. It is a required attribute, too, and its value is any valid document URL. The specified document is assumed to have a relationship to the current document.

7.7.2.2 The rel and rev attributes

The rel and rev attributes express the relationship between the source and target documents. The rel attribute specifies the relationship from the source document to the target; the rev attribute specifies the relationship from the target document to the source document. Both attributes can be included in a single tag.

The value of either attribute is a space-separated list of relationships. The actual relationship names are not specified by the HTML standard, although some have come into common usage as listed in section
Section 7.3.1.5, "The rel and rev attributes"
. For example, a document that is part of a sequence of documents might use: when referencing the next document in the series. The relationship from the source to the target is that of moving to the next document; the reverse relationship is that of moving to the previous document.

7.7.2.3 The title attribute

The title attribute lets you specify the title of the document to which you are linking. This attribute is useful when referencing a resource that does not have a title, such as an image or a non-HTML

Other books

Greed by Noire
Black Horn by A. J. Quinnell
The Winding Stair by Jane Aiken Hodge
A Beautiful Truth by Colin McAdam
Sins and Scarlet Lace by Liliana Hart
Explosive Passion by Dobson, Marissa
Teacher's Pet by Blaise, Rae Lynn
Competitions by Sharon Green
Ride by Cat Johnson
Ethel Merman: A Life by Brian Kellow