Home /Modules/html-spec/links.html

links.html

html-spec/specifications/prose/html-4.01/struct/links.html · 1288 line(s) · html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Links in HTML documents</title>
<link rel="previous" href="tables.html">
<link rel="next" href="objects.html">
<link rel="contents" href="../cover.html#toc">
<link rel="stylesheet" type="text/css" href= 
"http://www.w3.org/StyleSheets/TR/W3C-REC">
<link rel="STYLESHEET" href="../style/default.css" type="text/css">
</head>
<body>
<div class="navbar" align="center">&nbsp;<a href="tables.html">previous</a>
&nbsp; <a href="objects.html">next</a> &nbsp; <a href="../cover.html#minitoc">
contents</a> &nbsp; <a href="../index/elements.html">elements</a> &nbsp; <a
href="../index/attributes.html">attributes</a> &nbsp; <a href= 
"../index/list.html">index</a> 

<hr></div>

<h1 align="center"><a name="h-12">12</a> Links</h1>

<div class="subtoc">
<p><strong>Contents</strong></p>

<ol>
<li><a class="tocxref" href="#h-12.1">Introduction to links and anchors</a> 

<ol>
<li><a class="tocxref" href="#h-12.1.1">Visiting a linked resource</a></li>

<li><a class="tocxref" href="#h-12.1.2">Other link relationships</a></li>

<li><a class="tocxref" href="#h-12.1.3">Specifying anchors and links</a></li>

<li><a class="tocxref" href="#h-12.1.4">Link titles</a></li>

<li><a class="tocxref" href="#h-12.1.5">Internationalization and links</a></li>
</ol>
</li>

<li><a class="tocxref" href="#h-12.2">The <samp class="einst2">A</samp>
element</a> 

<ol>
<li><a class="tocxref" href="#h-12.2.1">Syntax of anchor names</a></li>

<li><a class="tocxref" href="#h-12.2.2">Nested links are illegal</a></li>

<li><a class="tocxref" href="#h-12.2.3">Anchors with the <samp>id</samp>
attribute</a></li>

<li><a class="tocxref" href="#h-12.2.4">Unavailable and unidentifiable
resources</a></li>
</ol>
</li>

<li><a class="tocxref" href="#h-12.3">Document relationships: the <samp class= 
"einst2">LINK</samp> element</a> 

<ol>
<li><a class="tocxref" href="#h-12.3.1">Forward and reverse links</a></li>

<li><a class="tocxref" href="#h-12.3.2">Links and external style
sheets</a></li>

<li><a class="tocxref" href="#h-12.3.3">Links and search engines</a></li>
</ol>
</li>

<li><a class="tocxref" href="#h-12.4">Path information: the <samp class=
"einst2">BASE</samp> element</a> 

<ol>
<li><a class="tocxref" href="#h-12.4.1"><span class="index-def" title= 
"URI::resolution of relative|resolution of relative URI">Resolving relative
URIs</span></a></li>
</ol>
</li>
</ol>
</div>

<h2><a name="h-12.1">12.1</a> <a name="links">Introduction to links</a> and <a
name="anchors">anchors</a></h2>

<p>HTML offers many of the conventional publishing idioms for rich text and
structured documents, but what separates it from most other markup languages is
its features for hypertext and interactive documents. This section introduces
the <em>link</em> (or hyperlink, or Web link), the basic hypertext construct. A
link is a connection from one Web resource to another. Although a simple
concept, the link has been one of the primary forces driving the success of the
Web.</p>

<p>A <span class="index-def" title="link::definition of"><a name="didx-link">
<dfn>link</dfn></a></span> has two ends -- called <span class="index-def"
title="anchor"><a name="didx-anchor"><dfn>anchors</dfn></a></span> -- and a
direction. The link starts at the "source" anchor and points to the
"destination" anchor, which may be any Web resource (e.g., an image, a video
clip, a sound bite, a program, an HTML document, an element within an HTML
document, etc.).</p>

<h3><a name="h-12.1.1">12.1.1</a> Visiting a linked resource</h3>

<p><span class="index-inst" title="link::used to retrieve resource"><a name= 
"idx-link-1">The default behavior associated with a link is the retrieval of
another Web resource.</a></span> This behavior is commonly and implicitly
obtained by selecting the link (e.g., by clicking, through keyboard input,
etc.).</p>

<div class="example">
<p>The following HTML excerpt contains <a name="two-links">two links</a>, one
whose destination anchor is an HTML document named "chapter2.html" and the
other whose destination anchor is a GIF image in the file "forest.gif":</p>

<pre>
&lt;BODY&gt;
<em>...some text...</em>
&lt;P&gt;You'll find a lot more in  &lt;A href="chapter2.html"&gt;chapter two&lt;/A&gt;. 
See also this &lt;A href="../images/forest.gif"&gt;map of the enchanted forest.&lt;/A&gt;
&lt;/BODY&gt;
</pre>
</div>

<p>By activating these links (by clicking with the mouse, through keyboard
input, voice commands, etc.), users may visit these resources. Note that the <a
href="links.html#adef-href" class="noxref"><samp class="ainst">href</samp></a>
attribute in each source anchor specifies the address of the destination anchor
with a URI.</p>

<p>The destination anchor of a link may be an element within an HTML document.
The destination anchor must be given an anchor name and any URI addressing this
anchor must include the name as its <span class="index-inst" title="fragment 
identifier"><a name="idx-fragment_identifier" href= 
"../intro/intro.html#fragment-uri">fragment identifier</a></span>.</p>

<p>Destination anchors in HTML documents may be specified either by the <a
href="links.html#edef-A" class="noxref"><samp class="einst">A</samp></a>
element (naming it with the <a href="links.html#adef-name-A" class="noxref">
<samp class="ainst-A">name</samp></a> attribute), or by any other element
(naming with the <a href="global.html#adef-id" class="noxref"><samp class=
"ainst">id</samp></a> attribute).</p>

<div class="example">
<p>Thus, for example, an author might create a table of contents whose entries
link to header elements <a href="global.html#edef-H2" class="noxref"><samp
class="einst">H2</samp></a>, <a href="global.html#edef-H3" class="noxref"><samp
class="einst">H3</samp></a>, etc., in the same document. Using the <a href= 
"links.html#edef-A" class="noxref"><samp class="einst">A</samp></a> element to
create destination anchors, we would write:</p>

<pre>
&lt;H1&gt;Table of Contents&lt;/H1&gt;
&lt;P&gt;&lt;A href="#section1"&gt;Introduction&lt;/A&gt;&lt;BR&gt;
&lt;A href="#section2"&gt;Some background&lt;/A&gt;&lt;BR&gt;
&lt;A href="#section2.1"&gt;On a more personal note&lt;/A&gt;&lt;BR&gt;
<em>...the rest of the table of contents...</em>
<em>...the document body...</em>
&lt;H2&gt;&lt;A name="section1"&gt;Introduction&lt;/A&gt;&lt;/H2&gt;
<em>...section 1...</em>
&lt;H2&gt;&lt;A name="section2"&gt;Some background&lt;/A&gt;&lt;/H2&gt;
<em>...section 2...</em>
&lt;H3&gt;&lt;A name="section2.1"&gt;On a more personal note&lt;/A&gt;&lt;/H3&gt;
<em>...section 2.1...</em>
</pre>

<p>We may achieve the same effect by making the header elements themselves the
anchors:</p>

<pre>
&lt;H1&gt;Table of Contents&lt;/H1&gt;
&lt;P&gt;&lt;A href="#section1"&gt;Introduction&lt;/A&gt;&lt;BR&gt;
&lt;A href="#section2"&gt;Some background&lt;/A&gt;&lt;BR&gt;
&lt;A href="#section2.1"&gt;On a more personal note&lt;/A&gt;&lt;BR&gt;
<em>...the rest of the table of contents...</em>
<em>...the document body...</em>
&lt;H2 id="section1"&gt;Introduction&lt;/H2&gt;
<em>...section 1...</em>
&lt;H2 id="section2"&gt;Some background&lt;/H2&gt;
<em>...section 2...</em>
&lt;H3 id="section2.1"&gt;On a more personal note&lt;/H3&gt;
<em>...section 2.1...</em>
</pre>
</div>

<h3><a name="h-12.1.2">12.1.2</a> <span class="index-inst" title="link::used to 
define relationship"><a name="idx-link-2">Other link
relationships</a></span></h3>

<p>By far the most common <em>use</em> of a link is to retrieve another Web
resource, as illustrated in the previous examples. However, authors may insert
links in their documents that express other relationships between resources
than simply "activate this link to visit that related resource". Links that
express other types of relationships have one or more <a href= 
"../types.html#type-links">link types</a> specified in their source anchor.</p>

<p>The <em>roles</em> of a link defined by <a href="links.html#edef-A" class= 
"noxref"><samp class="einst">A</samp></a> or <a href="links.html#edef-LINK"
class="noxref"><samp class="einst">LINK</samp></a> are specified via the <a
href="links.html#adef-rel" class="noxref"><samp class="ainst">rel</samp></a>
and <a href="links.html#adef-rev" class="noxref"><samp class="ainst">
rev</samp></a> attributes.</p>

<div class="example">
<p>For instance, links defined by the <a href="links.html#edef-LINK" class= 
"noxref"><samp class="einst">LINK</samp></a> element may describe the position
of a document within a series of documents. In the following excerpt, links
within the document entitled "Chapter 5" point to the previous and next
chapters:</p>

<pre>
&lt;HEAD&gt;
<em>...other head information...</em>
&lt;TITLE&gt;Chapter 5&lt;/TITLE&gt;
&lt;LINK rel="prev" href="chapter4.html"&gt;
&lt;LINK rel="next" href="chapter6.html"&gt;
&lt;/HEAD&gt;
</pre>

<p>The link type of the first link is "prev" and that of the second is "next"
(two of several recognized <a href="../types.html#type-links">link types</a>).
Links specified by <a href="links.html#edef-LINK" class="noxref"><samp class= 
"einst">LINK</samp></a> are <strong>not</strong> rendered with the document's
contents, although user agents may render them in other ways (e.g., as
navigation tools).</p>

<p>Even if they are not used for navigation, these links may be interpreted in
interesting ways. For example, a user agent that prints a series of HTML
documents as a single document may use this link information as the basis of
forming a coherent linear document. Further information is given below on using
<a href="#search">links for the benefit of search engines.</a></p>
</div>

<h3><a name="h-12.1.3">12.1.3</a> Specifying anchors and links</h3>

<p>Although several HTML elements and attributes create links to other
resources (e.g., the <a href="objects.html#edef-IMG" class="noxref"><samp
class="einst">IMG</samp></a> element, the <a href= 
"../interact/forms.html#edef-FORM" class="noxref"><samp class="einst">
FORM</samp></a> element, etc.), this chapter discusses links and anchors
created by the <a href="links.html#edef-LINK" class="noxref"><samp class=
"einst">LINK</samp></a> and <a href="links.html#edef-A" class="noxref"><samp
class="einst">A</samp></a> elements. The <a href="links.html#edef-LINK" class= 
"noxref"><samp class="einst">LINK</samp></a> element may only appear in the
head of a document. The <a href="links.html#edef-A" class="noxref"><samp class= 
"einst">A</samp></a> element may only appear in the body.</p>

<p>When the <a href="links.html#edef-A" class="noxref"><samp class="einst">
A</samp></a> element's <a href="links.html#adef-href" class="noxref"><samp
class="ainst-A">href</samp></a> attribute is set, the element defines a source
anchor for a link that may be activated by the user to retrieve a Web resource.
The source anchor is the location of the <a href="links.html#edef-A" class= 
"noxref"><samp class="einst">A</samp></a> instance and the destination anchor
is the Web resource.</p>

<p>The retrieved resource may be handled by the user agent in several ways: by
opening a new HTML document in the same user agent window, opening a new HTML
document in a different window, starting a new program to handle the resource,
etc. Since the <a href="links.html#edef-A" class="noxref"><samp class="einst">
A</samp></a> element has content (text, images, etc.), user agents may render
this content in such a way as to indicate the presence of a link (e.g., by
underlining the content).</p>

<p>When the <a href="links.html#adef-name-A" class="noxref"><samp class=
"ainst-A">name</samp></a> or <a href="global.html#adef-id" class="noxref"><samp
class="ainst">id</samp></a> attributes of the <a href="links.html#edef-A"
class="noxref"><samp class="einst">A</samp></a> element are set, the element
defines an anchor that may be the destination of other links.</p>

<p>Authors may set the <a href="links.html#adef-name-A" class="noxref"><samp
class="ainst-A">name</samp></a> and <a href="links.html#adef-href" class=
"noxref"><samp class="ainst-A">href</samp></a> attributes simultaneously in the
same <a href="links.html#edef-A" class="noxref"><samp class="einst">
A</samp></a> instance.</p>

<p>The <a href="links.html#edef-LINK" class="noxref"><samp class="einst">
LINK</samp></a> element defines a relationship between the current document and
another resource. Although <a href="links.html#edef-LINK" class="noxref"><samp
class="einst">LINK</samp></a> has no content, the relationships it defines may
be rendered by some user agents.</p>

<h3><a name="h-12.1.4">12.1.4</a> <span class="index-inst" title="link::title
of"><a name="idx-link-3">Link titles</a></span></h3>

<p>The <a href="global.html#adef-title" class="noxref"><samp class="ainst">
title</samp></a> attribute may be set for both <a href="links.html#edef-A"
class="noxref"><samp class="einst">A</samp></a> and <a href= 
"links.html#edef-LINK" class="noxref"><samp class="einst">LINK</samp></a> to
add information about the nature of a link. This information may be spoken by a
user agent, rendered as a tool tip, cause a change in cursor image, etc.</p>

<div class="example">
<p>Thus, we may augment a <a href="#two-links">previous example</a> by
supplying a title for each link:</p>

<pre>
&lt;BODY&gt;
<em>...some text...</em>
&lt;P&gt;You'll find a lot more in &lt;A href="chapter2.html"
       title="Go to chapter two"&gt;chapter two&lt;/A&gt;.
&lt;A href="./chapter2.html"
       title="Get chapter two."&gt;chapter two&lt;/A&gt;. 
See also this &lt;A href="../images/forest.gif"
       title="GIF image of enchanted forest"&gt;map of
the enchanted forest.&lt;/A&gt;
&lt;/BODY&gt;
</pre>
</div>

<h3><a name="h-12.1.5">12.1.5</a> <span class="index-inst" title="link::and 
character encoding|character encoding::of links"><a name="idx-link-4">
Internationalization and links</a></span></h3>

<p>Since links may point to documents encoded with different <a href= 
"../charset.html#doc-char-set">character encodings</a>, the <a href= 
"links.html#edef-A" class="noxref"><samp class="einst">A</samp></a> and <a
href="links.html#edef-LINK" class="noxref"><samp class="einst">LINK</samp></a>
elements support the <a href="links.html#adef-charset" class="noxref"><samp
class="ainst">charset</samp></a> attribute. This attribute allows authors to
advise user agents about the encoding of data at the other end of the link.</p>

<p><span class="index-inst" title="language::of linked resource">The <a name= 
"idx-language" href="links.html#adef-hreflang" class="noxref"><samp class=
"ainst">hreflang</samp></a> attribute</span> provides user agents with
information about the language of a resource at the end of a link, just as the
<a href="dirlang.html#adef-lang" class="noxref"><samp class="ainst">
lang</samp></a> attribute provides information about the language of an
element's content or attribute values.</p>

<p>Armed with this additional knowledge, user agents should be able to avoid
presenting "garbage" to the user. Instead, they may either locate resources
necessary for the correct presentation of the document or, if they cannot
locate the resources, they should at least warn the user that the document will
be unreadable and explain the cause.</p>

<h2><a name="h-12.2">12.2</a> The <a name="edef-A"><samp class="edef">
A</samp></a> element</h2>

<div class="dtd-fragment">
<pre class="dtd-fragment">
&lt;!ELEMENT <a href="links.html#edef-A" class="noxref"><samp class=
"einst">A</samp></a> - - (<a href=
"../sgml/dtd.html#inline">%inline;</a>)* -(A)       -- anchor --&gt;
&lt;!ATTLIST A
  <a href=
"../sgml/dtd.html#attrs">%attrs;</a>                              -- <a href= 
"../sgml/dtd.html#coreattrs">%coreattrs</a>, <a href=
"../sgml/dtd.html#i18n">%i18n</a>, <a href=
"../sgml/dtd.html#events">%events</a> --
  <a href="links.html#adef-charset" class="noxref"><samp class=
"ainst-A">charset</samp></a>     <a href=
"../sgml/dtd.html#Charset">%Charset;</a>      #IMPLIED  -- char encoding of linked resource --
  <a href="links.html#adef-type-A" class="noxref"><samp class=
"ainst-A">type</samp></a>        <a href=
"../sgml/dtd.html#ContentType">%ContentType;</a>  #IMPLIED  -- advisory content type --
  <a href="links.html#adef-name-A" class="noxref"><samp class=
"ainst-A">name</samp></a>        <a href=
"../types.html#type-cdata">CDATA</a>          #IMPLIED  -- named link end --
  <a href="links.html#adef-href" class="noxref"><samp class=
"ainst-A">href</samp></a>        <a href=
"../sgml/dtd.html#URI">%URI;</a>          #IMPLIED  -- URI for linked resource --
  <a href="links.html#adef-hreflang" class="noxref"><samp class=
"ainst-A">hreflang</samp></a>    <a href=
"../sgml/dtd.html#LanguageCode">%LanguageCode;</a> #IMPLIED  -- language code --
  <a href="links.html#adef-rel" class="noxref"><samp class=
"ainst-A">rel</samp></a>         <a href=
"../sgml/dtd.html#LinkTypes">%LinkTypes;</a>    #IMPLIED  -- forward link types --
  <a href="links.html#adef-rev" class="noxref"><samp class=
"ainst-A">rev</samp></a>         <a href=
"../sgml/dtd.html#LinkTypes">%LinkTypes;</a>    #IMPLIED  -- reverse link types --
  <a href="../interact/forms.html#adef-accesskey" class="noxref"><samp class= 
"ainst-A">accesskey</samp></a>   <a href=
"../sgml/dtd.html#Character">%Character;</a>    #IMPLIED  -- accessibility key character --
  <a href="objects.html#adef-shape" class="noxref"><samp class=
"ainst-A">shape</samp></a>       <a href=
"../sgml/dtd.html#Shape">%Shape;</a>        rect      -- for use with client-side image maps --
  <a href="objects.html#adef-coords" class="noxref"><samp class=
"ainst-A">coords</samp></a>      <a href=
"../sgml/dtd.html#Coords">%Coords;</a>       #IMPLIED  -- for use with client-side image maps --
  <a href="../interact/forms.html#adef-tabindex" class="noxref"><samp class= 
"ainst-A">tabindex</samp></a>    <a href=
"../types.html#type-number">NUMBER</a>         #IMPLIED  -- position in tabbing order --
  <a href="../interact/scripts.html#adef-onfocus" class="noxref"><samp class= 
"ainst-A">onfocus</samp></a>     <a href=
"../sgml/dtd.html#Script">%Script;</a>       #IMPLIED  -- the element got the focus --
  <a href="../interact/scripts.html#adef-onblur" class="noxref"><samp class= 
"ainst-A">onblur</samp></a>      <a href=
"../sgml/dtd.html#Script">%Script;</a>       #IMPLIED  -- the element lost the focus --
  &gt;
</pre>
</div>

<p><em>Start tag: <strong>required</strong>, End tag: <strong>
required</strong></em></p>

<div class="adef-list">
<p><em>Attribute definitions</em></p>

<dl>
<dt><a name="adef-name-A"><samp class="adef">name</samp></a> = <a href= 
"../types.html#type-cdata"><em>cdata</em></a> <a href= 
"../types.html#case-sensitive">[CS]</a></dt>

<dd>This attribute names the current anchor so that it may be the destination
of another link. The value of this attribute must be a unique anchor name. The
scope of this name is the current document. Note that this attribute shares the
same name space as the <a href="global.html#adef-id" class="noxref"><samp
class="ainst">id</samp></a> attribute.</dd>

<dt><a name="adef-href"><samp class="adef">href</samp></a> = <a href= 
"../types.html#type-uri"><em>uri</em></a> <a href= 
"../types.html#see-type-for-case">[CT]</a></dt>

<dd>This attribute specifies the location of a Web resource, thus defining a
link between the current element (the source anchor) and the destination anchor
defined by this attribute.</dd>

<dt><a name="adef-hreflang"><samp class="adef">hreflang</samp></a> = <a href= 
"../types.html#type-langcode"><em>langcode</em></a> <a href= 
"../types.html#case-insensitive">[CI]</a></dt>

<dd>This attribute specifies the base language of the resource designated by <a
href="links.html#adef-href" class="noxref"><samp class="ainst">href</samp></a>
and may only be used when <a href="links.html#adef-href" class="noxref"><samp
class="ainst">href</samp></a> is specified.</dd>

<dt><a name="adef-type-A"><samp class="adef">type</samp></a> = <a href= 
"../types.html#type-content-type"><em>content-type</em></a> <a href= 
"../types.html#case-insensitive">[CI]</a></dt>

<dd>This attribute gives an advisory hint as to the content type of the content
available at the link target address. It allows user agents to opt to use a
fallback mechanism rather than fetch the content if they are advised that they
will get content in a content type they do not support.</dd>

<dd>Authors who use this attribute take responsibility to manage the risk that
it may become inconsistent with the content available at the link target
address.</dd>

<dd>For the current list of registered content types, please consult <a rel= 
"biblioentry" href="../references.html#ref-MIMETYPES" class="normref">
[MIMETYPES]</a>.</dd>

<dt><a name="adef-rel"><samp class="adef">rel</samp></a> = <a href= 
"../types.html#type-links"><em>link-types</em></a> <a href= 
"../types.html#case-insensitive">[CI]</a></dt>

<dd>This attribute describes the relationship from the current document to the
anchor specified by the <a href="links.html#adef-href" class="noxref"><samp
class="ainst">href</samp></a> attribute. The value of this attribute is a
space-separated list of link types.</dd>

<dt><a name="adef-rev"><samp class="adef">rev</samp></a> = <a href= 
"../types.html#type-links"><em>link-types</em></a> <a href= 
"../types.html#case-insensitive">[CI]</a></dt>

<dd>This attribute is used to describe a <a href="#rev-link">reverse link</a>
from the anchor specified by the <a href="links.html#adef-href" class="noxref">
<samp class="ainst">href</samp></a> attribute to the current document. The
value of this attribute is a space-separated list of link types.</dd>

<dt><a name="adef-charset"><samp class="adef">charset</samp></a> = <a href= 
"../types.html#type-charset"><em>charset</em></a> <a href= 
"../types.html#case-insensitive">[CI]</a></dt>

<dd>This attribute specifies the character encoding of the resource designated
by the link. Please consult the section on <a href="../charset.html">character
encodings</a> for more details.</dd>
</dl>
</div>

<div class="aref-list">
<p><em>Attributes defined elsewhere</em></p>

<ul>
<li><a href="global.html#adef-id" class="noxref"><samp class="ainst">
id</samp></a>, <a href="global.html#adef-class" class="noxref"><samp class= 
"ainst">class</samp></a> (<a href=
"../struct/global.html#id-and-class">document-wide identifiers</a>)</li>

<li><a href="dirlang.html#adef-lang" class="noxref"><samp class="ainst">
lang</samp></a> (<a href="../struct/dirlang.html#language-info">language
information</a>), <a href="dirlang.html#adef-dir" class="noxref"><samp class= 
"ainst">dir</samp></a> (<a href="../struct/dirlang.html#bidirection">text
direction</a>)</li>

<li><a href="global.html#adef-title" class="noxref"><samp class="ainst">
title</samp></a> (<a href="../struct/global.html#title">element title</a>)</li>

<li><a href="../present/styles.html#adef-style" class="noxref"><samp class= 
"ainst">style</samp></a> (<a href="../present/styles.html#style-element">inline
style information</a> )</li>

<li><a href="objects.html#adef-shape" class="noxref"><samp class="ainst">
shape</samp></a> and <a href="objects.html#adef-coords" class="noxref"><samp
class="ainst">coords</samp></a> (<a href="objects.html#include-maps">image
maps</a>)</li>

<li><a href="../interact/scripts.html#adef-onfocus" class="noxref"><samp class= 
"ainst">onfocus</samp></a>, <a href="../interact/scripts.html#adef-onblur"
class="noxref"><samp class="ainst">onblur</samp></a>, <a href= 
"../interact/scripts.html#adef-onclick" class="noxref"><samp class="ainst">
onclick</samp></a>, <a href="../interact/scripts.html#adef-ondblclick" class= 
"noxref"><samp class="ainst">ondblclick</samp></a>, <a href= 
"../interact/scripts.html#adef-onmousedown" class="noxref"><samp class="ainst">
onmousedown</samp></a>, <a href="../interact/scripts.html#adef-onmouseup"
class="noxref"><samp class="ainst">onmouseup</samp></a>, <a href= 
"../interact/scripts.html#adef-onmouseover" class="noxref"><samp class="ainst">
onmouseover</samp></a>, <a href="../interact/scripts.html#adef-onmousemove"
class="noxref"><samp class="ainst">onmousemove</samp></a>, <a href= 
"../interact/scripts.html#adef-onmouseout" class="noxref"><samp class="ainst">
onmouseout</samp></a>, <a href="../interact/scripts.html#adef-onkeypress"
class="noxref"><samp class="ainst">onkeypress</samp></a>, <a href= 
"../interact/scripts.html#adef-onkeydown" class="noxref"><samp class="ainst">
onkeydown</samp></a>, <a href="../interact/scripts.html#adef-onkeyup" class= 
"noxref"><samp class="ainst">onkeyup</samp></a> (<a href= 
"../interact/scripts.html#events">intrinsic events</a> )</li>

<li><a href="../present/frames.html#adef-target" class="noxref"><samp class= 
"ainst">target</samp></a> (<a href="../present/frames.html#target-info">target
frame information</a>)</li>

<li><a href="../interact/forms.html#adef-tabindex" class="noxref"><samp class= 
"ainst">tabindex</samp></a> (<a href=
"../interact/forms.html#tabbing-navigation">tabbing navigation</a>)</li>

<li><a href="../interact/forms.html#adef-accesskey" class="noxref"><samp class= 
"ainst">accesskey</samp></a> (<a href=
"../interact/forms.html#access-keys">access keys</a>)</li>
</ul>
</div>

<p><span class="index-inst" title="anchor::creation of with A">Each <a name= 
"idx-anchor-1" href="links.html#edef-A" class="noxref"><samp class="einst">
A</samp></a> element defines an anchor</span></p>

<ol>
<li>The <a href="links.html#edef-A" class="noxref"><samp class="einst">
A</samp></a> element's content defines the position of the anchor.</li>

<li>The <a href="links.html#adef-name-A" class="noxref"><samp class="ainst-A">
name</samp></a> attribute names the anchor so that it may be the destination of
zero or more links (see also <a href="#anchors-with-id">anchors with <samp>
id</samp></a>).</li>

<li>The <a href="links.html#adef-href" class="noxref"><samp class="ainst-A">
href</samp></a> attribute makes this anchor the source anchor of exactly one
link.</li>
</ol>

<p>Authors may also create an <a href="links.html#edef-A" class="noxref"><samp
class="einst">A</samp></a> element that specifies no anchors, i.e., that
doesn't specify <a href="links.html#adef-href" class="noxref"><samp class= 
"ainst-A">href</samp></a>, <a href="links.html#adef-name-A" class="noxref">
<samp class="ainst-A">name</samp></a>, or <a href="global.html#adef-id" class= 
"noxref"><samp class="ainst">id</samp></a>. Values for these attributes may be
set at a later time through <span class="index-inst" title="anchor::set by 
script|script::used to set anchor"><a name="idx-anchor-2" href= 
"../interact/scripts.html">scripts.</a></span></p>

<div class="example">
<p>In the example that follows, the <a href="links.html#edef-A" class="noxref">
<samp class="einst">A</samp></a> element defines a link. The source anchor is
the text "W3C Web site" and the destination anchor is "http://www.w3.org/":</p>

<pre>
For more information about W3C, please consult the 
&lt;A href="http://www.w3.org/"&gt;W3C Web site&lt;/A&gt;. 
</pre>

<p>This link designates the home page of the World Wide Web Consortium. When a
user activates this link in a user agent, the user agent will retrieve the
resource, in this case, an HTML document.</p>

<p><span class="index-inst" title="link::rendering of"><a name="idx-link-5">
User agents generally render links</a></span> in such a way as to make them
obvious to users (underlining, reverse video, etc.). The exact rendering
depends on the user agent. Rendering may vary according to whether the user has
already visited the link or not. A possible visual rendering of the previous
link might be:</p>

<pre>
For more information about W3C, please consult the W3C Web site.
                                                   ~~~~~~~~~~~~
</pre>

<p>To tell user agents explicitly what the character encoding of the
destination page is, set the <a href="links.html#adef-charset" class="noxref">
<samp class="ainst">charset</samp></a> attribute:</p>

<pre>
For more information about W3C, please consult the 
&lt;A href="http://www.w3.org/" charset="ISO-8859-1"&gt;W3C Web site&lt;/A&gt; 
</pre>
</div>

<div class="example">
<p>Suppose we define an anchor named "anchor-one" in the file "one.html".</p>

<pre>
<em>...text before the anchor...</em>
&lt;A name="anchor-one"&gt;This is the location of anchor one.&lt;/A&gt;
<em>...text after the anchor...</em>
</pre>

<p>This creates an anchor around the text "This is the location of anchor
one.". Usually, the contents of <a href="links.html#edef-A" class="noxref">
<samp class="einst">A</samp></a> are not rendered in any special way when <a
href="links.html#edef-A" class="noxref"><samp class="einst">A</samp></a>
defines an anchor only.</p>

<p>Having defined the anchor, we may link to it from the same or another
document. URIs that designate anchors contain a "#" character followed by the
anchor name (the <a href="../intro/intro.html#fragment-uri">fragment
identifier</a>). Here are some examples of such URIs:</p>

<ul>
<li>An absolute URI: <tt>http://www.mycompany.com/one.html#anchor-one</tt></li>

<li>A relative URI: <tt>./one.html#anchor-one</tt> or <tt>
one.html#anchor-one</tt></li>

<li>When the link is defined in the same document: <tt>#anchor-one</tt></li>
</ul>

<p>Thus, a link defined in the file "two.html" in the same directory as
"one.html" would refer to the anchor as follows:</p>

<pre>
<em>...text before the link...</em>
For more information, please consult &lt;A href="./one.html#anchor-one"&gt; anchor one&lt;/A&gt;.
<em>...text after the link...</em>
</pre>
</div>

<div class="example">
<p>The <a href="links.html#edef-A" class="noxref"><samp class="einst">
A</samp></a> element in the following example specifies a link (with <a href= 
"links.html#adef-href" class="noxref"><samp class="ainst-A">href</samp></a>)
and creates a named anchor (with <a href="links.html#adef-name-A" class=
"noxref"><samp class="ainst-A">name</samp></a>) simultaneously:</p>

<pre>
I just returned from vacation! Here's a
&lt;A name="anchor-two" 
   href="http://www.somecompany.com/People/Ian/vacation/family.png"&gt;
photo of my family at the lake.&lt;/A&gt;.
</pre>

<p>This example contains a link to a different type of Web resource (a PNG
image). Activating the link should cause the image resource to be retrieved
from the Web (and possibly displayed if the system has been configured to do
so).</p>
</div>

<div class="note">
<p><em><strong>Note.</strong> User agents should be able to find anchors
created by empty <a href="links.html#edef-A" class="noxref"><samp class=
"einst">A</samp></a> elements, but some fail to do so. For example, some user
agents may not find the "empty-anchor" in the following HTML fragment:</em></p>

<pre>
&lt;A name="empty-anchor"&gt;&lt;/A&gt;
&lt;EM&gt;...some HTML...&lt;/EM&gt;
&lt;A href="#empty-anchor"&gt;Link to empty anchor&lt;/A&gt;
</pre>
</div>

<h3><a name="h-12.2.1">12.2.1</a> <span class="index-inst" title= 
"anchor::syntax of name"><a name="idx-anchor-3">Syntax of anchor
names</a></span></h3>

<p>An anchor name is the value of either the <a href="links.html#adef-name-A"
class="noxref"><samp class="ainst-A">name</samp></a> or <a href= 
"global.html#adef-id" class="noxref"><samp class="ainst">id</samp></a>
attribute when used in the context of anchors. Anchor names must observe the
following rules:</p>

<ul>
<li><span class="index-inst" title="anchor::uniqueness of name"><a name= 
"idx-anchor-4"><strong>Uniqueness:</strong></a></span> Anchor names must be
unique within a document. Anchor names that differ only in case may not appear
in the same document.</li>

<li><span class="index-inst" title="anchor::case of name|case::of anchor name">
<a name="idx-anchor-5"><strong>String matching:</strong></a></span> Comparisons
between <a href="../intro/intro.html#fragment-uri">fragment identifiers</a> and
anchor names must be done by exact (case-sensitive) match.</li>
</ul>

<div class="example">
<p>Thus, the following example is correct with respect to string matching and
must be considered a match by user agents:</p>

<pre>
&lt;P&gt;&lt;A href="#xxx"&gt;...&lt;/A&gt;
<em>...more document...</em>
&lt;P&gt;&lt;A name="xxx"&gt;...&lt;/A&gt;
</pre>
</div>

<div class="illegal-example">
<p><span class="example-title">ILLEGAL EXAMPLE:</span>
<br>
The following example is illegal with respect to uniqueness since the two names
are the same except for case:</p>

<pre>
&lt;P&gt;&lt;A name="xxx"&gt;...&lt;/A&gt;
&lt;P&gt;&lt;A name="XXX"&gt;...&lt;/A&gt;
</pre>
</div>

<div class="example">
<p>Although the following excerpt is legal HTML, the behavior of the user agent
is not defined; some user agents may (incorrectly) consider this a match and
others may not.</p>

<pre>
&lt;P&gt;&lt;A href="#xxx"&gt;...&lt;/A&gt;
<em>...more document...</em>
&lt;P&gt;&lt;A name="XXX"&gt;...&lt;/A&gt;
</pre>
</div>

<p><span class="index-inst" title="anchor::ASCII characters in name"><a name= 
"idx-anchor-6">Anchor names should be restricted to ASCII
characters.</a></span> Please consult the appendix for more information about
<a href="../appendix/notes.html#non-ascii-chars">non-ASCII characters in URI
attribute values</a>.</p>

<h3><a name="h-12.2.2">12.2.2</a> <span class="index-inst" title="link::nesting 
illegal"><a name="idx-link-6">Nested links are illegal</a></span></h3>

<p>Links and anchors defined by the <a href="links.html#edef-A" class="noxref">
<samp class="einst">A</samp></a> element must not be nested; an <a href= 
"links.html#edef-A" class="noxref"><samp class="einst">A</samp></a> element
must not contain any other <a href="links.html#edef-A" class="noxref"><samp
class="einst">A</samp></a> elements.</p>

<p>Since the DTD defines the <a href="links.html#edef-LINK" class="noxref">
<samp class="einst">LINK</samp></a> element to be empty, <a href= 
"links.html#edef-LINK" class="noxref"><samp class="einst">LINK</samp></a>
elements may not be nested either.</p>

<h3><a name="h-12.2.3">12.2.3</a> <span class="index-inst" title= 
"anchor::creation with id attribute"><a name="anchors-with-id">Anchors with the
<samp>id</samp> attribute</a></span></h3>

<p>The <a href="global.html#adef-id" class="noxref"><samp class="ainst">
id</samp></a> attribute may be used to create an anchor at the start tag of any
element (including the <a href="links.html#edef-A" class="noxref"><samp class= 
"einst">A</samp></a> element).</p>

<div class="example">
<p>This example illustrates the use of the <a href="global.html#adef-id" class= 
"noxref"><samp class="ainst">id</samp></a> attribute to position an anchor in
an <a href="global.html#edef-H2" class="noxref"><samp class="einst">
H2</samp></a> element. The anchor is linked to via the <a href= 
"links.html#edef-A" class="noxref"><samp class="einst">A</samp></a>
element.</p>

<pre>
You may read more about this in &lt;A href="#section2"&gt;Section Two&lt;/A&gt;.
<em>...later in the document</em>
&lt;H2 id="section2"&gt;Section Two&lt;/H2&gt;
<em>...later in the document</em>
&lt;P&gt;Please refer to &lt;A href="#section2"&gt;Section Two&lt;/A&gt; above
for more details.
</pre>
</div>

<div class="example">
<p>The following example names a destination anchor with the <a href= 
"global.html#adef-id" class="noxref"><samp class="ainst">id</samp></a>
attribute:</p>

<pre>
I just returned from vacation! Here's a
&lt;A id="anchor-two"&gt;photo of my family at the lake.&lt;/A&gt;.
</pre>
</div>

<p>The <a href="global.html#adef-id" class="noxref"><samp class="ainst">
id</samp></a> and <a href="links.html#adef-name-A" class="noxref"><samp class= 
"ainst-A">name</samp></a> attributes share the same <span class="index-inst"
title="anchor::name space of|id attribute::same name space as name attribute">
<a name="idx-anchor-8">name space.</a></span> This means that they cannot both
define an anchor with the same name in the same document. It is permissible to
use both attributes to specify an element's unique identifier for the following
elements: <a href="links.html#edef-A" class="noxref"><samp class="einst">
A</samp></a>, <a href="objects.html#edef-APPLET" class="noxref"><samp class= 
"einst">APPLET</samp></a>, <a href="../interact/forms.html#edef-FORM" class= 
"noxref"><samp class="einst">FORM</samp></a>, <a href= 
"../present/frames.html#edef-FRAME" class="noxref"><samp class="einst">
FRAME</samp></a>, <a href="../present/frames.html#edef-IFRAME" class="noxref">
<samp class="einst">IFRAME</samp></a>, <a href="objects.html#edef-IMG" class= 
"noxref"><samp class="einst">IMG</samp></a>, and <a href=
"objects.html#edef-MAP" class="noxref"><samp class="einst">MAP</samp></a>. When
both attributes are used on a single element, their values must be
identical.</p>

<div class="illegal-example">
<p><span class="example-title">ILLEGAL EXAMPLE:</span>
<br>
The following excerpt is illegal HTML since these attributes declare the same
name twice in the same document.</p>

<pre>
&lt;A href="#a1"&gt;...&lt;/A&gt;
...
&lt;H1 id="a1"&gt;
<em>...pages and pages...</em>
&lt;A name="a1"&gt;&lt;/A&gt;
</pre>
</div>

<div class="example">
<p>The following example illustrates that <a href="global.html#adef-id" class= 
"noxref"><samp class="ainst-A">id</samp></a> and <a href=
"links.html#adef-name-A" class="noxref"><samp class="ainst-A">name</samp></a>
must be the same when both appear in an element's start tag:</p>

<pre>
&lt;P&gt;&lt;A name="a1" id="a1" href="#a1"&gt;...&lt;/A&gt;
</pre>
</div>

<p>Because of its specification in the HTML DTD, the <a href= 
"links.html#adef-name-A" class="noxref"><samp class="ainst-A">name</samp></a>
attribute may contain <span class="index-inst" title="anchor::character 
references in name"><a name="idx-anchor-9" href="../charset.html#entities">
character references</a></span>. Thus, the value <tt>D&amp;#xfc;rst</tt> is a
valid <a href="links.html#adef-name-A" class="noxref"><samp class="ainst-A">
name</samp></a> attribute value, as is <tt>D&amp;uuml;rst</tt> . The <a href= 
"global.html#adef-id" class="noxref"><samp class="ainst">id</samp></a>
attribute, on the other hand, may not contain character references.</p>

<div class="note">
<p><em><strong>Use <a href="global.html#adef-id" class="noxref"><samp class= 
"ainst">id</samp></a> or <a href="links.html#adef-name-A" class="noxref"><samp
class="ainst-A">name</samp></a>?</strong> Authors should consider the following
issues when <span class="index-inst" title="anchor::with A vs. id"><a name= 
"idx-anchor-10">deciding</a></span> whether to use <a href=
"global.html#adef-id" class="noxref"><samp class="ainst">id</samp></a> or <a
href="links.html#adef-name-A" class="noxref"><samp class="ainst-A">
name</samp></a> for an anchor name:</em></p>

<ul>
<li><em>The <a href="global.html#adef-id" class="noxref"><samp class="ainst">
id</samp></a> attribute can act as more than just an anchor name (e.g., style
sheet selector, processing identifier, etc.).</em></li>

<li><em>Some older user agents don't support anchors created with the <a href= 
"global.html#adef-id" class="noxref"><samp class="ainst">id</samp></a>
attribute.</em></li>

<li><em>The <a href="links.html#adef-name-A" class="noxref"><samp class=
"ainst-A">name</samp></a> attribute allows richer anchor names (with <a href= 
"../charset.html#entities">entities</a>).</em></li>
</ul>
</div>

<h3><a name="h-12.2.4">12.2.4</a> <span class="index-inst" title= 
"error::unavailable resource"><a name="idx-error">Unavailable and
unidentifiable resources</a></span></h3>

<p>A reference to an unavailable or unidentifiable resource is an error.
Although user agents may vary in how they handle such an error, we recommend
the following behavior:</p>

<ul>
<li>If a user agent cannot locate a linked resource, it should alert the
user.</li>

<li>If a user agent cannot identify the type of a linked resource, it should
still attempt to process it. It should alert the user and may allow the user to
intervene and identify the document type.</li>
</ul>

<h2><a name="h-12.3">12.3</a> Document relationships: the <a name="edef-LINK">
<samp class="edef">LINK</samp></a> element</h2>

<div class="dtd-fragment">
<pre class="dtd-fragment">
&lt;!ELEMENT <a href="links.html#edef-LINK" class="noxref"><samp class=
"einst">LINK</samp></a> - O EMPTY               -- a media-independent link --&gt;
&lt;!ATTLIST LINK
  <a href=
"../sgml/dtd.html#attrs">%attrs;</a>                              -- <a href= 
"../sgml/dtd.html#coreattrs">%coreattrs</a>, <a href=
"../sgml/dtd.html#i18n">%i18n</a>, <a href=
"../sgml/dtd.html#events">%events</a> --
  <a href="links.html#adef-charset" class="noxref"><samp class=
"ainst-LINK">charset</samp></a>     <a href=
"../sgml/dtd.html#Charset">%Charset;</a>      #IMPLIED  -- char encoding of linked resource --
  <a href="links.html#adef-href" class="noxref"><samp class=
"ainst-LINK">href</samp></a>        <a href=
"../sgml/dtd.html#URI">%URI;</a>          #IMPLIED  -- URI for linked resource --
  <a href="links.html#adef-hreflang" class="noxref"><samp class=
"ainst-LINK">hreflang</samp></a>    <a href=
"../sgml/dtd.html#LanguageCode">%LanguageCode;</a> #IMPLIED  -- language code --
  <a href="links.html#adef-type-A" class="noxref"><samp class=
"ainst-A">type</samp></a>        <a href=
"../sgml/dtd.html#ContentType">%ContentType;</a>  #IMPLIED  -- advisory content type --
  <a href="links.html#adef-rel" class="noxref"><samp class=
"ainst-LINK">rel</samp></a>         <a href=
"../sgml/dtd.html#LinkTypes">%LinkTypes;</a>    #IMPLIED  -- forward link types --
  <a href="links.html#adef-rev" class="noxref"><samp class=
"ainst-LINK">rev</samp></a>         <a href=
"../sgml/dtd.html#LinkTypes">%LinkTypes;</a>    #IMPLIED  -- reverse link types --
  <a href="../present/styles.html#adef-media" class="noxref"><samp class= 
"ainst-LINK">media</samp></a>       <a href=
"../sgml/dtd.html#MediaDesc">%MediaDesc;</a>    #IMPLIED  -- for rendering on these media --
  &gt;
</pre>
</div>

<p><em>Start tag: <strong>required</strong>, End tag: <strong>
forbidden</strong></em></p>

<div class="aref-list">
<p><em>Attributes defined elsewhere</em></p>

<ul>
<li><a href="global.html#adef-id" class="noxref"><samp class="ainst">
id</samp></a>, <a href="global.html#adef-class" class="noxref"><samp class= 
"ainst">class</samp></a> (<a href=
"../struct/global.html#id-and-class">document-wide identifiers</a>)</li>

<li><a href="dirlang.html#adef-lang" class="noxref"><samp class="ainst">
lang</samp></a> (<a href="../struct/dirlang.html#language-info">language
information</a>), <a href="dirlang.html#adef-dir" class="noxref"><samp class= 
"ainst">dir</samp></a> (<a href="../struct/dirlang.html#bidirection">text
direction</a>)</li>

<li><a href="global.html#adef-title" class="noxref"><samp class="ainst">
title</samp></a> (<a href="../struct/global.html#title">element title</a>)</li>

<li><a href="../present/styles.html#adef-style" class="noxref"><samp class= 
"ainst">style</samp></a> (<a href="../present/styles.html#style-element">inline
style information</a> )</li>

<li><a href="../interact/scripts.html#adef-onclick" class="noxref"><samp class= 
"ainst">onclick</samp></a>, <a href="../interact/scripts.html#adef-ondblclick"
class="noxref"><samp class="ainst">ondblclick</samp></a>, <a href= 
"../interact/scripts.html#adef-onmousedown" class="noxref"><samp class="ainst">
onmousedown</samp></a>, <a href="../interact/scripts.html#adef-onmouseup"
class="noxref"><samp class="ainst">onmouseup</samp></a>, <a href= 
"../interact/scripts.html#adef-onmouseover" class="noxref"><samp class="ainst">
onmouseover</samp></a>, <a href="../interact/scripts.html#adef-onmousemove"
class="noxref"><samp class="ainst">onmousemove</samp></a>, <a href= 
"../interact/scripts.html#adef-onmouseout" class="noxref"><samp class="ainst">
onmouseout</samp></a>, <a href="../interact/scripts.html#adef-onkeypress"
class="noxref"><samp class="ainst">onkeypress</samp></a>, <a href= 
"../interact/scripts.html#adef-onkeydown" class="noxref"><samp class="ainst">
onkeydown</samp></a>, <a href="../interact/scripts.html#adef-onkeyup" class= 
"noxref"><samp class="ainst">onkeyup</samp></a> (<a href= 
"../interact/scripts.html#events">intrinsic events</a> )</li>

<li><a href="links.html#adef-href" class="noxref"><samp class="ainst">
href</samp></a>, <a href="links.html#adef-hreflang" class="noxref"><samp class= 
"ainst">hreflang</samp></a>, <a href="links.html#adef-type-A" class="noxref">
<samp class="ainst-A">type</samp></a>, <a href="links.html#adef-rel" class= 
"noxref"><samp class="ainst">rel</samp></a>, <a href="links.html#adef-rev"
class="noxref"><samp class="ainst">rev</samp></a> (<a href="#links">links and
anchors</a>)</li>

<li><a href="../present/frames.html#adef-target" class="noxref"><samp class= 
"ainst">target</samp></a> (<a href="../present/frames.html#target-info">target
frame information</a>)</li>

<li><a href="../present/styles.html#adef-media" class="noxref"><samp class= 
"ainst">media</samp></a> (<a href="../present/styles.html#style-group">header
style information</a>)</li>

<li><a href="links.html#adef-charset" class="noxref"><samp class="ainst">
charset</samp></a>(<a href="../charset.html#doc-char-set">character
encodings</a>)</li>
</ul>
</div>

<p>This element defines a link. Unlike <a href="links.html#edef-A" class=
"noxref"><samp class="einst">A</samp></a>, it may only appear in the <a href= 
"global.html#edef-HEAD" class="noxref"><samp class="einst">HEAD</samp></a>
section of a document, although it may appear any number of times. Although <a
href="links.html#edef-LINK" class="noxref"><samp class="einst">LINK</samp></a>
has no content, it conveys relationship information that may be rendered by
user agents in a variety of ways (e.g., a tool-bar with a drop-down menu of
links).</p>

<div class="example">
<p>This example illustrates how several <a href="links.html#edef-LINK" class= 
"noxref"><samp class="einst">LINK</samp></a> definitions may appear in the <a
href="global.html#edef-HEAD" class="noxref"><samp class="einst">HEAD</samp></a>
section of a document. The current document is "Chapter2.html". The <a href= 
"links.html#adef-rel" class="noxref"><samp class="ainst">rel</samp></a>
attribute specifies the relationship of the linked document with the current
document. The values "Index", "Next", and "Prev" are explained in the section
on <a href="../types.html#type-links">link types</a>.</p>

<pre>
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;HTML&gt;
&lt;HEAD&gt;
  &lt;TITLE&gt;Chapter 2&lt;/TITLE&gt;
  &lt;LINK rel="Index" href="../index.html"&gt;
  &lt;LINK rel="Next"  href="Chapter3.html"&gt;
  &lt;LINK rel="Prev"  href="Chapter1.html"&gt;
&lt;/HEAD&gt;
<em>...the rest of the document...</em>
</pre>
</div>

<h3><a name="h-12.3.1">12.3.1</a> <span class="index-inst" title="link::forward 
and reverse"><a name="rev-link">Forward and reverse links</a></span></h3>

<p>The <a href="links.html#adef-rel" class="noxref"><samp class="ainst">
rel</samp></a> and <a href="links.html#adef-rev" class="noxref"><samp class= 
"ainst">rev</samp></a> attributes play complementary roles -- the <a href= 
"links.html#adef-rel" class="noxref"><samp class="ainst">rel</samp></a>
attribute specifies a forward link and the <a href="links.html#adef-rev" class= 
"noxref"><samp class="ainst">rev</samp></a> attribute specifies a reverse
link.</p>

<p>Consider two documents A and B.</p>

<pre>
Document A:       &lt;LINK href="docB" rel="foo"&gt;
</pre>

<p>Has exactly the same meaning as:</p>

<pre>
Document B:       &lt;LINK href="docA" rev="foo"&gt;
</pre>

<p>Both attributes may be specified simultaneously.</p>

<h3><a name="h-12.3.2">12.3.2</a> <span class="index-inst" title="link::and 
external style sheets|style sheet::external through links"><a name=
"linksandss">Links and external style sheets</a></span></h3>

<p>When the <a href="links.html#edef-LINK" class="noxref"><samp class="einst">
LINK</samp></a> element links an external style sheet to a document, the <a
href="links.html#adef-type-A" class="noxref"><samp class="ainst-A">
type</samp></a> attribute specifies the style sheet language and the <a href= 
"../present/styles.html#adef-media" class="noxref"><samp class="ainst">
media</samp></a> attribute specifies the intended rendering medium or media.
User agents may save time by retrieving from the network only those style
sheets that apply to the current device.</p>

<p><a href="../present/styles.html#media-types">Media types</a> are further
discussed in the section on style sheets.</p>

<h3><a name="h-12.3.3">12.3.3</a> <span class="index-inst" title="search 
engine::and links"><a name="search">Links and search engines</a></span></h3>

<p>Authors may use the <a href="links.html#edef-LINK" class="noxref"><samp
class="einst">LINK</samp></a> element to provide a variety of information to
search engines, including:</p>

<ul>
<li>Links to alternate versions of a document, written in another human
language.</li>

<li>Links to alternate versions of a document, designed for different media,
for instance a version especially suited for printing.</li>

<li>Links to the starting page of a collection of documents.</li>
</ul>

<p>The examples below illustrate how language information, media types, and
link types may be combined to improve document handling by search engines.</p>

<div class="example">
<p>In the following example, we use the <a href="links.html#adef-hreflang"
class="noxref"><samp class="ainst">hreflang</samp></a> attribute to tell search
engines where to find Dutch, Portuguese, and Arabic versions of a document.
Note the use of the <a href="links.html#adef-charset" class="noxref"><samp
class="ainst">charset</samp></a> attribute for the Arabic manual. Note also the
use of the <a href="dirlang.html#adef-lang" class="noxref"><samp class="ainst">
lang</samp></a> attribute to indicate that the value of the <a href= 
"global.html#adef-title" class="noxref"><samp class="ainst">title</samp></a>
attribute for the <a href="links.html#edef-LINK" class="noxref"><samp class= 
"einst">LINK</samp></a> element designating the French manual is in French.</p>

<pre>
&lt;HEAD&gt;
&lt;TITLE&gt;The manual in English&lt;/TITLE&gt;
&lt;LINK title="The manual in Dutch"
      type="text/html"
      rel="alternate"
      hreflang="nl" 
      href="http://someplace.com/manual/dutch.html"&gt;
&lt;LINK title="The manual in Portuguese"
      type="text/html"
      rel="alternate"
      hreflang="pt" 
      href="http://someplace.com/manual/portuguese.html"&gt;
&lt;LINK title="The manual in Arabic"
      type="text/html"
      rel="alternate"
      charset="ISO-8859-6"
      hreflang="ar" 
      href="http://someplace.com/manual/arabic.html"&gt;
&lt;LINK lang="fr" title="La documentation en Fran&amp;ccedil;ais"
      type="text/html"
      rel="alternate"
      hreflang="fr"
      href="http://someplace.com/manual/french.html"&gt;
&lt;/HEAD&gt;
</pre>
</div>

<div class="example">
<p>In the following example, we tell search engines where to find the printed
version of a manual.</p>

<pre>
&lt;HEAD&gt;
&lt;TITLE&gt;Reference manual&lt;/TITLE&gt;
&lt;LINK media="print" title="The manual in postscript"
      type="application/postscript"
      rel="alternate"
      href="http://someplace.com/manual/postscript.ps"&gt;
&lt;/HEAD&gt;
</pre>
</div>

<div class="example">
<p>In the following example, we tell search engines where to find the front
page of a collection of documents.</p>

<pre>
&lt;HEAD&gt;
&lt;TITLE&gt;Reference manual -- Page 5&lt;/TITLE&gt;
&lt;LINK rel="Start" title="The first page of the manual"
      type="text/html"
      href="http://someplace.com/manual/start.html"&gt;
&lt;/HEAD&gt;
</pre>
</div>

<p>Further information is given in the notes in the appendix on <a href= 
"../appendix/notes.html#recs">helping search engines index your Web
site</a>.</p>

<h2><a name="h-12.4">12.4</a> Path information: the <a name="edef-BASE"><samp
class="edef">BASE</samp></a> element</h2>

<div class="dtd-fragment">
<pre class="dtd-fragment">
&lt;!ELEMENT <a href="links.html#edef-BASE" class="noxref"><samp class=
"einst">BASE</samp></a> - O EMPTY               -- document base URI --&gt;
&lt;!ATTLIST BASE
  <a href="links.html#adef-href-BASE" class="noxref"><samp class=
"ainst-BASE">href</samp></a>        <a href=
"../sgml/dtd.html#URI">%URI;</a>          #REQUIRED -- URI that acts as base URI --
  &gt;
</pre>
</div>

<p><em>Start tag: <strong>required</strong>, End tag: <strong>
forbidden</strong></em></p>

<div class="adef-list">
<p><em>Attribute definitions</em></p>

<dl>
<dt><a name="adef-href-BASE"><samp class="adef">href</samp></a> = <a href= 
"../types.html#type-uri"><em>uri</em></a> <a href= 
"../types.html#see-type-for-case">[CT]</a></dt>

<dd>This attribute specifies an absolute URI that acts as the base URI for
resolving relative URIs.</dd>
</dl>
</div>

<div class="aref-list">
<p><em>Attributes defined elsewhere</em></p>

<ul>
<li><a href="../present/frames.html#adef-target" class="noxref"><samp class= 
"ainst">target</samp></a> (<a href="../present/frames.html#target-info">target
frame information</a>)</li>
</ul>
</div>

<p>In HTML, links and references to external images, applets, form-processing
programs, style sheets, etc. are always specified by a URI. Relative URIs are
<a href="#resolving-relative-uris">resolved</a> according to a base URI, which
may come from a variety of sources. The <a href="links.html#edef-BASE" class= 
"noxref"><samp class="einst">BASE</samp></a> element allows authors <span
class="index-inst" title="base URI|URI::specifying base"><a name=
"idx-base_URI">to specify a document's base URI explicitly.</a></span></p>

<p>When present, the <a href="links.html#edef-BASE" class="noxref"><samp class= 
"einst">BASE</samp></a> element must appear in the <a href= 
"global.html#edef-HEAD" class="noxref"><samp class="einst">HEAD</samp></a>
section of an HTML document, before any element that refers to an external
source. The path information specified by the <a href="links.html#edef-BASE"
class="noxref"><samp class="einst">BASE</samp></a> element only affects URIs in
the document where the element appears.</p>

<div class="example">
<p>For example, given the following <a href="links.html#edef-BASE" class=
"noxref"><samp class="einst">BASE</samp></a> declaration and <a href= 
"links.html#edef-A" class="noxref"><samp class="einst">A</samp></a>
declaration:</p>

<pre>
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;HTML&gt;
 &lt;HEAD&gt;
   &lt;TITLE&gt;Our Products&lt;/TITLE&gt;
   &lt;BASE href="http://www.aviary.com/products/intro.html"&gt;
 &lt;/HEAD&gt;

 &lt;BODY&gt;
   &lt;P&gt;Have you seen our &lt;A href="../cages/birds.gif"&gt;Bird Cages&lt;/A&gt;?
 &lt;/BODY&gt;
&lt;/HTML&gt;
</pre>

<p>the relative URI "../cages/birds.gif" would resolve to:</p>

<pre>
http://www.aviary.com/cages/birds.gif
</pre>
</div>

<h3><a name="h-12.4.1">12.4.1</a> <span class="index-def" title= 
"URI::resolution of relative|resolution of relative URI"><a name= 
"resolving-relative-uris">Resolving relative URIs</a></span></h3>

<p>User agents must calculate the base URI for resolving relative URIs
according to <a rel="biblioentry" href="../references.html#ref-RFC1808" class= 
"normref">[RFC1808]</a>, section 3. The following describes how <a rel= 
"biblioentry" href="../references.html#ref-RFC1808" class="normref">
[RFC1808]</a> applies specifically to HTML.</p>

<p>User agents must calculate the base URI according to the following
precedences (highest priority to lowest):</p>

<ol>
<li>The base URI is set by the <a href="links.html#edef-BASE" class="noxref">
<samp class="einst">BASE</samp></a> element.</li>

<li>The base URI is given by meta data discovered during a protocol
interaction, such as an HTTP header (see <a rel="biblioentry" href= 
"../references.html#ref-RFC2616" class="normref">[RFC2616]</a>).</li>

<li>By default, the base URI is that of the current document. Not all HTML
documents have a base URI (e.g., a valid HTML document may appear in an email
and may not be designated by a URI). Such HTML documents are considered
erroneous if they contain relative URIs and rely on a default base URI.</li>
</ol>

<p>Additionally, the <a href="objects.html#edef-OBJECT" class="noxref"><samp
class="einst">OBJECT</samp></a> and <a href="objects.html#edef-APPLET" class= 
"noxref"><samp class="einst">APPLET</samp></a> elements define attributes that
take precedence over the value set by the <a href="links.html#edef-BASE" class= 
"noxref"><samp class="einst">BASE</samp></a> element. Please consult the
definitions of these elements for more information about URI issues specific to
them.</p>

<div class="note">
<p><em><strong>Note.</strong> For versions of HTTP that define a Link header,
user agents should handle these headers exactly as <a href=
"links.html#edef-LINK" class="noxref"><samp class="einst">LINK</samp></a>
elements in the document. HTTP 1.1 as defined by <a rel="biblioentry" href= 
"../references.html#ref-RFC2616" class="informref">[RFC2616]</a> does not
include a Link header field (refer to section 19.6.3).</em></p>
</div>

<div class="navbar" align="center">
<hr><a href="tables.html">previous</a> &nbsp; <a href="objects.html">next</a>
&nbsp; <a href="../cover.html#minitoc">contents</a> &nbsp; <a href= 
"../index/elements.html">elements</a> &nbsp; <a href=
"../index/attributes.html">attributes</a> &nbsp; <a href="../index/list.html">
index</a></div>
</body>
</html>