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.
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 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
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.
Below is an example of a link created by using the <a> tag.
In an HTML tag, attributes dictate certain aspects of an HTML element. Attributes are made up of a name and value pair. All HTML 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.
|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 the linked file.|
|title||Describes the link and shows description when hovering over the link.|
|type||Designates the linked file's media type.|
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.
|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.|
|All versions||All versions||All versions||All version||All versions||All versions|