a ElementThe a element is an inline element declared by the XHTML 1.1 Hypertext Module
This is the only element in this Module.
The a element is primarily used to
create hyperlinks. The link's target is a
URI which is specified by the
href attribute (which is of type URI).
Optionally, the language of the content at that URI (and/or its
character set) may be stated using the
the hreflang attribute (and/or charset attribute).
If the content at the target URI is of an unusual
MIME type,
you may want to specify this using the
type attribute -
this content type information is usually provided as an indication to the
user agent which may, for example, decide not to try to follow a link to
an unsupported MIME type. Note that it is the responsibility of the document's
author to ensure that the information provided in the
hreflang, charset and type attributes is correct.
The title
attribute may be used to supply additional information about the link's
target, although the element's content should provide a basic description.
Links with uninformative content - such as "here", "click here"
and "this link" - should be avoided. Many assistive technologies - such as screen readers -
present their users with a list of all the links on a page, out of context. Link text
such as "click here" is next-to-useless for these users. Good link text
is more than just an accessibility consideration, however: it makes content
much more informative to those scanning a website for the first time...
and first impressions count!
Historically, the a element was known as the
'anchor' element since it was commonly used to specify an anchor point
mid-way through a document. This point in the document could then be linked to directly
- by another hyperlink - using the name attribute of the anchor element
as a fragment identifier.
In more modern browsers, however, an anchor point may be created at
almost any element, simply by adding an id attribute
which is then used as the fragment identifier. The name
attribute of the a element has been removed in XHTML 1.1.
Of course, there is nothing to stop you creating an anchor such as
<
in XHTML 1.1, but there is no need:
h2><a id="sect2">Section 2</a></h2>< would do equally well.
Whilst it is true that some very old browsers don't support
h2 id="sect2">Section 2</h2>id attributes as fragment identifiers, they are so outdated that this is no longer seen as an issue
(ref: W3C Note (work in progress)
*XHTML Media Types - Compatibility Guidelines - Item A.8).
The relationship between the current page and the target page may be
specified using the rel
or rev attributes.
For example, in a page of technical specifications, the hyperlink to a glossary
of terms may include the rel="glossary"
attribute: rel
defines a forward relationship. Alternatively, the glossary page itself
may contain a link to the technical specifications with the attribute
rev="glossary" since
rev defines
a reverse relationship. For more information on values for these two
attributes, see the LinkTypes
attribute type.
A few examples:
<a href="http://www.lemonde.fr/" hreflang="fr"><span xml:lang="fr">Le Monde</span> in French</a><a href="soundtrack.mp3" type="audio/mpeg">Soundtrack Sample</a><p>Skip to <a href="#content">Page Content</a></p><a href="glossary.html" rel="glossary">Glossary</a> (link in technical.html)<a href="technical.html" rev="glossary">Technical Information</a> (link in glossary.html)See the map element for details on
using the a element in client side image maps.
There are no #REQUIRED attributes on the a element.
a element are listed below:accesskey [ type Character ]charset [ type Charset ]href attributehref [ type URI ]hreflang [ type LanguageCode ]href attribute (should not be used if href is not specified)rel [ type LinkTypes ]href attribute - e.g. a value of "glossary" specifies that the resource is a glossary for the current document (if desired, a space separated list of relationships may be given)rev [ type LinkTypes ]href attribute - i.e. the relationship from that other resource to the current document - e.g. a value of "glossary" specifies that the current document is a glossary for the resource (if desired, a space separated list of relationships may be given)tabindex [ type Number ]type [ type ContentType ]href attributecoords [ type Coords ]shapeshape [ type Shape (rect | circle | poly | default) - default="rect" ]coords attribute specifies the shape's dimensionsonblur [ type Script ]onfocus [ type Script ]target [ type FrameTarget ]a element are listed below:class [ type NMTOKENS ]id [ type ID ]style [ type CDATA ], from the Style Attribute Module (deprecated)title [ type Text ]xmlns [ type URI - #FIXED 'http://www.w3.org/1999/xhtml' ]dir [ type Enumeration (ltr | rtl) ], from the Bi-directional Text Modulexml:lang [ type LanguageCode ]All attributes in the
Events Attribute Collection
are supported:onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup
a element is:
( #PCDATA | InlNoAnchor.mix )*
See Content Model & Nesting for information about Content Model syntax and Nesting Groups.
aabbr, acronym, br, cite, code, dfn, em, kbd, q, samp, span, strong, varbutton, input, label, select, textareaimgb, big, i, small, sub, sup, ttmapnoscript, scriptdel, insbdoobjectrubyNote:
An a element must never contain another a element, at any nesting depth.
See Descendant Exclusions.
aabbr, acronym, address, cite, code, dfn, div, em, h1 - h6, kbd, p, pre, q, samp, span, strong, vardd, dt, licaption, td, thfieldset, label, legendb, big, i, small, sub, sup, ttdel, insbdoobjectrb, rt