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 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
With the absolute link example, unless the page changes on Computer Hope, it's valid regardless of where it's placed.
Below is an example of a link created 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 contains the available HTML attributes for the <a> tag with a description.
|download||Designates the file that will be downloaded upon clicking the link.|
|href||Designates the URL 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.|
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|