HTML <a> tag
The HTML <a> tag is an inline HTML (hypertext markup language) 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 and related attributes and browser compatibility.
Examples of <a> tag
Relative link example
<a href="html.htm">Our HTML overview</a>
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 example on your computer you would get an error. 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 is on our absolute path definition.
Absolute link example
<a href="https://www.computerhope.com/jargon/h/html.htm">HTML</a>
With the absolute link example, unless the page changes on Computer Hope, it's valid regardless of where it's placed.
Example result
Below is an example of a link created using the <a> tag.
Attributes
All HTML tags support standard attributes that define the settings of an HTML element. In addition to the standard settings, the <a> tag has the following unique attributes.
Attribute | Description |
---|---|
download | Designates the file that will be downloaded upon clicking the link. |
href | Designates the URL (uniform resource locator) of the web page. |
hreflang | Designates the language of the link. |
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 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
In addition to the above attributes, the <a> tag had the following deprecated attributes.
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
Edge | Internet Explorer | Firefox | Safari | Opera | Chrome |
---|---|---|---|---|---|
All versions | All versions | All versions | All version | All versions | All versions |
Browser, Compatibility, Container tag, CSS, Nofollow, URL, Web design terms