HTML <a> tag

Updated: 10/11/2017 by Computer Hope

The HTML a tag.The HTML <a> tag is an inline HTML element that defines a hyperlink. Hyperlinks allow users to navigate from one page to another. The following sections contain information about this tag, including examples of how it is used as well as related attributes and browser compatibility.

Example

HTML a tag

Relative link example

<a href="html.htm">Our HTML overview</a>

Note: The example is a relative link, which means that unless the file "html.htm" existed in the same directory you would get a 404 error. This file exists on our server, so the link works, but if you used the same relative link example on your computer you would get an error because the file does not exist. If you wanted to point to the file on our server from your computer, you would use the absolute link example. Further information about absolute and relative paths and links can be found in our absolute path definition.

Absolute link example

<a href="https://www.computerhope.com/jargon/h/html.htm">HTML definition.</a>

With the absolute link example unless the page changes on the Computer Hope server the link is valid regardless of how the page is loaded.

Example Result

Our HTML overview.

Attributes

Within an HTML tag, an attribute dictates certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. The following table shows all of the current unique HTML attributes for the <a> tag, as well as a description of each.

Attribute Description
download Designates the file that will be downloaded upon clicking the link.
href Designates the URL of the web page to which the link points.
hreflang Designates the language of the file to which the link points.
media Designates the device the linked file is optimized for using.
rel Designates the relationship between the linked and current files.
target Designates where to open a the linked file.
title Describes the link and shows description when hovering over the link.
type Designates the linked file's media type.

Deprecated attributes

A deprecated attribute is one that may function currently but is not supported in going forward. While the attribute may work with the current version of HTML, it will eventually be phased out. It is better to avoid using these attributes to help future-proof your website.

Attribute Description
charset Designates the character-set of the linked file
coords Designates the coordinates of the linked file
name Designates the name of an anchor
rev Designates the relationship between the linked and current files
shape Designates the shape of the linked file

Compatibility

Internet Explorer Firefox Safari Opera Chrome
All versions All versions All version All versions All versions

Browser, Compatibility, CSS, URL, Web design terms