a

FilterElements

<a> ... </a>

Defines an anchor that can be used as a hypertext link or a named fragment within the document. When the href attribute is set to a valid URI, the anchor is a hypertext link to a web page, page fragment, or another resource. The name or id attributes are used to label an anchor and allow it to serve as the destination point of a link. An a element may have both href and name/id attributes.

Notes

In HTML5, the href attribute may be omitted to use an a element as a "placeholder link." HTML5 also permits flow content (block elements) within a elements.

Start/End Tags

Required/Required

Specifications

  • HTML 4.01
  • HTML5

charset=

Values: Character set
Not in HTML5. Specifies the character encoding of the target document.

coords=

Values: x,y coordinates
Not in HTML5. Specifies the x/y-coordinates for a clickable area in an image map. The HTML 4.01 Recommendation proposes that client-side image maps be replaced with an object element containing the image and a set of anchor elements defining the "hot" areas (with shapes and coordinate attributes). This system has not been implemented by browsers and has been dropped in HTML5.

href=

Values: URI
Specifies the location of the destination document or web resource (such as an image, audio, PDF, or other media file).

hreflang=

Values: language code
Specifies the base language of the target document.

id=

Values: text
Gives the link a unique name (similar to the name attribute) so that it can be referenced from a link, script, or style sheet. In XHTML, the id attribute is required for document fragments. For backward compatibility, authors use both name and id for fragments.

media=

Values: all |aural | braille | handheld | print | projection | screen | tty | tv
HTML5 only. Describes the media for which the target document was designed. The default is all.

name=

Values: text
Not in HTML5. XHTML documents use id for document fragments. Places a fragment identifier within an HTML document.

ping=

Values: URLs
HTML5 only. Specifies a list of URLs that must be contacted when the link is followed, useful for user tracking.

rel=

Values: link type keyword
Describes one or more relationships from the current source document to the linked document. The link types specified in both the HTML 4.01 and 5 specifications are alternate, bookmark, help, index, next, and prev.

The HTML 4.01-only keywords include: appendix, chapter, contents, copyright, glossary, section, start, and subsection.

The following link types are specified in HTML5 only: archives, author, external, first, last, license, nofollow, noreferrer, search, sidebar, tag, and up.

rev=

Values: link type keyword (see rel attribute)
Not in HTML5. Specifies one or more relationships from the target back to the source (the opposite of the rel attribute).

shape=

Values: rect | circle | poly | default
Not in HTML5. Defines the shape of a clickable area in an image map. This is part of HTML 4.01’s proposal to replace client-side image maps with a combination of object and a elements. This system has not been implemented by browsers and was dropped in HTML5.

target=

Values: text
Specifies the name of the window or frame in which the target document should be displayed.

type=

Values: MIME type
Specifies the media or content type (MIME type) of the linked content—for example, text/html.
To a local file:
<a href="filename.html">Linked text</a>

(See sample below.)

To an external file:
<a href="http://server/path/
file.html"> ... </a>
To a named anchor:
<a href="http://server/path/
file.html#fragment"> ... </a>
To a named anchor in the current file:
<a href="#fragment"> ... </a>
To send an email message:
<a href="mailto:username@domain"> ... </a>
To a file on an FTP server:
<a href="ftp://server/path/
filename"> ... </a>
Creating a named anchor in HTML:
<a name="fragment"> ... </a>
Creating a named anchor in XHTML

(note that some authors also include a redundant name for backward compatibility with version 4 browsers):

<a id="fragment"> ... </a>

Rendered example

Linked text