HTML: The Markup Language

ahyperlink # T

The a element represents a hyperlink.

Permitted content #

Permitted attributes #

Descriptions for attributes specific to this element #

name = ID OBSOLETE
Specifies that its a element is a named hyperlink, with the name given by the value of this attribute.
The name attribute on the a element is obsolete. Consider putting an id attribute on the nearest container instead.
href = URI
A URL that provides the destination of the hyperlink. If the href attribute is not specified, the element represents a placeholder hyperlink.
target = browsing-context name or keyword CHANGED
A name or keyword giving a browsing context for UAs to use when following the hyperlink.
The target attribute on the a element was deprecated in a previous version of HTML, but is no longer deprecated, as it useful in Web applications, particularly in combination with the iframe element.
rel = tokens
A list of tokens that specify the relationship between the document containing the hyperlink and the destination indicated by the hyperlink.
hreflang = language tag
The language of the destination of the hyperlink.
media = media-query list NEW
The media for which the destination of the hyperlink was designed.
type = MIME type
The MIME type of the destination of the hyperlink.
ping = list of URIs NEW
A list of URLs to notify if a user follows the hyperlink.

Additional constraints and admonitions #

Tag omission #

An a element must have both a start tag and an end tag.

Permitted parent elements #

any element that can contain phrasing elements, any element that can contain flow elements

Details #

If the contents of an a element are empty, the element represents an empty hyperlink.

Although previous versions of HTML restricted the a element to only containing phrasing content, the a element is now transparent; and so is now also allowed to contain flow content if its parent element is is allowed to contain flow content.

DOM interface #

interface HTMLAnchorElement : HTMLElement {
  stringifier attribute DOMString href;
           attribute DOMString target;
           attribute DOMString ping;
           attribute DOMString rel;
  readonly attribute DOMTokenList relList;
           attribute DOMString media;
           attribute DOMString hreflang;
           attribute DOMString type;

           attribute DOMString text;

  // URL decomposition IDL attributes
           attribute DOMString protocol;
           attribute DOMString host;
           attribute DOMString hostname;
           attribute DOMString port;
           attribute DOMString pathname;
           attribute DOMString search;
           attribute DOMString hash;
};

Typical default display properties #

a:link, a:visited {
color: (internal value);
text-decoration: underline;
cursor: auto; }
a:link:active, a:visited:active {
color: (internal value); }