Start tag: required, End tag: required Attribute definitions - name = cdata [CS]
- 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 id attribute.
- href = uri [CT]
- 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.
- hreflang = langcode [CI]
- This attribute specifies the base language of the resource designated by href and may only be used when href is specified.
- type = content-type [CI]
- 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.
- 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].
- rel = link-types [CI]
- This attribute describes the relationship from the current document to the anchor specified by the href attribute. The value of this attribute is a space-separated list of link types.
- rev = link-types [CI]
- This attribute is used to describe a reverse link from the anchor specified by the href attribute to the current document. The value of this attribute is a space-separated list of link types.
- charset = charset [CI]
- This attribute specifies the character encoding of the resource designated by the link. Please consult the section on character encodings for more details.
Attributes defined elsewhere - id, class (document-wide identifiers)
- lang (language information), dir (text direction)
- title (element title)
- style (inline style information )
- shape and coords (image maps)
- onfocus, onblur, onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup (intrinsic events )
- target (target frame information)
- tabindex (tabbing navigation)
- accesskey (access keys)
Each A element defines an anchor - The A element's content defines the position of the anchor.
- The name attribute names the anchor so that it may be the destination of zero or more links (see also anchors with id).
- The href attribute makes this anchor the source anchor of exactly one link.
Authors may also create an A element that specifies no anchors, i.e., that doesn't specify href, name, or id. Values for these attributes may be set at a later time through scripts. 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 HTML 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: - An absolute URI: http://www.mycompany.com/one.html#anchor-one
- A relative URI: ./one.html#anchor-one or one.html#anchor-one
- When the link is defined in the same document: #anchor-one
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 name) simultaneously: I just returned from vacation! Here's a
<A name="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 should be able to find anchors created by empty A elements, but some fail to do so. For example, some user agents may not find the "empty-anchor" in the following HTML fragment: <A name="empty-anchor"></A>
<EM>...some HTML...</EM>
<A href="#empty-anchor">Link to empty anchor</A>
|