HTML and CSS Reference
In-Depth Information
Creating a Semantic Link
The text of a hypertext link should always describe to users the type of document that the
link opens. You can also use the
rel
attribute to indicate the type of document that a link
calls. For example, in the links to the site's home page, Gerry could insert the following
rel
attribute, setting its value to
fi rst
to indicate that the home page is the fi rst document
in the CAMshots Web site:
<a href=”home.htm” rel=”fi rst”>Home Page</a>
A hypertext link containing the
rel
attribute is called a
semantic link
because the tag
contains information about the relationship between the link and its destination. This
information is not intended for the user, but for the browser. For example, a browser
could be set up to mark the fi rst Web page in a site with a special icon or to provide
scripts that allow quick access to a site's fi rst page.
Although the
rel
attribute is not limited to a fi xed set of values, the specifi cations for
HTML and XHTML include a proposed list of special values. Figure 2-46 shows some of
these proposed relationship values.
Figure 2-46
Proposed values for the rel attribute
rel Attribute
Link To …
alternate
An alternate version of the document
archives
A collection of historical documents
author
Information about the author of the document
external
An external document
first
The first document in a selection
help
A help document
index
An index for the document
last
The last document in a selection
license
Copyright information for the document
next
The next document in a selection
prev
The previous document in a selection
search
A search tool for the selection
sidebar
A document that should be shown in the browser's sidebar
stylesheet
An external style sheet
HTML 4.01 and XHTML also support the
rev
attribute to describe the reverse relation-
ship: how a linked document views the current document. For example, if you're linking
to the Glossary page from the home page, the reverse relation is
fi rst
(because that is how
the Glossary page views the home page). The HTML code would be
<a href=”glossary.htm” rel=”glossary” rev=”fi rst”>Glossary</a>
The
rev
attribute is not supported in HTML5.
At this point, Gerry decides against using the
rel
and
rev
attributes on his Web site.
However, he'll keep them in mind as an option as his Web site expands in size and
complexity.