Contents
This section is normative.
The Hypertext Module provides the element that is used to define hypertext links to other resources, as well as a number of attributes.
This module supports the following element:
Element | Attributes | Minimal Content Model |
---|---|---|
a | Common, charset (Charset), hreflang (LanguageCode), rel (LinkTypes), rev (LinkTypes), type (ContentType) | (PCDATA | Inline)* |
This module adds the a element to the Inline content set of the Text Module, and activates the Hypertext Attribute Collection.
Implementation: DTD
Attributes
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.
For the current list of registered content types, please consult [MIMETYPES].
The navigation order defines the order in which elements will receive focus when navigated by the user via the keyboard. The navigation order may include elements nested within other elements.
Elements that may receive focus should be navigated by user agents according to the following rules:
Tabbing keys. The actual key sequence that causes navigation or element activation depends on the configuration of the user agent (e.g., the "tab" key is used for navigation and the "enter" key is used to activate a selected element).
User agents may also define key sequences to navigate the navigation order in reverse. When the end (or beginning) of the navigation order is reached, user agents may circle back to the beginning (or end).
Each a element defines an anchor.
Authors may also create an a element that specifies no anchors, i.e., that doesn't specify href, or id. Values for these attributes may be set at a later time through scripts as defined in the Scripting module.
In the example that follows, the a element defines a link. The source anchor is the text "W3C Web site" and the destination anchor is "http://www.w3.org/":
For more information about W3C, please consult the <a href="http://www.w3.org/">W3C Web site</a>.
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 XHTML document.
User agents generally render links 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:
For more information about W3C, please consult the W3C Web site. ~~~~~~~~~~~~
To tell user agents explicitly what the character encoding of the destination page is, set the charset attribute:
For more information about W3C, please consult the <a href="http://www.w3.org/" charset="ISO-8859-1">W3C Web site</a>
Suppose we define an anchor named "anchor-one" in the file "one.html".
...text before the anchor... <a name="anchor-one">This is the location of anchor one.</a> ...text after the anchor...
This creates an anchor around the text "This is the location of anchor one.". Usually, the contents of a are not rendered in any special way when a defines an anchor only.
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 fragment identifier). Here are some examples of such URIs:
Thus, a link defined in the file "two.html" in the same directory as "one.html" would refer to the anchor as follows:
...text before the link... For more information, please consult <a href="./one.html#anchor-one"> anchor one</a>. ...text after the link...
The a element in the following example specifies a link (with href) and creates a named anchor (with id) simultaneously:
I just returned from vacation! Here's a <a id="anchor-two" href="http://www.somecompany.com/People/Ian/vacation/family.png"> photo of my family at the lake.</a>.
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).
Note. User agents area required to find anchors created by empty a elements.