This section is normative.
The Hypertext Module provides an element that traditionally has been used in HTML to define hypertext links to other resources. Although all elements may now play the role of a hyperlink (using the href attribute) or hyperlink anchor (using the id attribute), this element remains for explicit markup of links, though is otherwise identical in semantics to the span element.
This module supports the following element:
|Element||Attributes||Minimal Content Model|
|a||Common||(PCDATA | Inline)*|
This module adds the a element to the Inline content set of the Text Module.
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. ~~~~~~~~~~~~
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...
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...
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 are required to find anchors created by empty a elements.