English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML reference manual

HTML tag大全

HTML: <a> Tag

The HTML <a> tag defines a hyperlink pointing to a URL or target in an HTML document. This tag is also commonly referred to as the <a> element.

Online Examples

Link to the Basic Tutorial Website :

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>Basic Tutorial Website(oldtoolbag.com)</title> 
</head>
<body>
<a href="https://www.oldtoolbag.com">Visit the Basic Tutorial Website!</a>/a>
</body>
</html>
Test and see ‹/›

Browser compatibility

IEFirefoxOperaChromeSafari

All mainstream browsers support the <a> tag.

Tag definition and usage instructions

The <a> tag defines a hyperlink, used to link from one page to another.

The most important attribute of the <a> element is the href attribute, which specifies the target of the link.

In all browsers, the default appearance of links is as follows:

  • Unvisited links are underlined and blue

  • Visited links are underlined and purple

  • Active links are underlined and red

Tips and Notes

  •   The HTML <a> element is located within the <body> tag.

  •   Start with <a> and end with/The text between <a> and </a> will be displayed as hyperlink text (i.e., underlined text).

  •   If you want the resource to open in a new window, please use the target =" _ blank" attribute. For example, you can write a hyperlink as follows: <a href="/examples/filename.html" target="_blank">Link to filename</a>

HTML 4.01 with HTML5differences

In HTML 4.01 In Chinese, the <a> tag can be both a hyperlink and an anchor. In HTML5 In Chinese, the <a> tag is a hyperlink, but if it does not have the href attribute, it is just a placeholder for a hyperlink.

HTML5 There are some new attributes and some HTML attributes are no longer supported. 4.01 attributes.

Attribute

New : HTML5 new attributes in

AttributeValueDescription
charsetchar_encodingHTML5 Not supported. Specifies the character encoding of the target URL.
coordscoordinatesHTML5 Not supported. Specifies the coordinates of the link.
downloadHTML5filenameSpecifies the download link
hrefURLSpecifies the target URL of the link.
hreflanglanguage_codeSpecifies the base language of the target URL. Used only when the href attribute exists.
mediaHTML5media_querySpecifies the media type of the target URL. Default value: all. Used only when the href attribute exists.
namesection_nameHTML5 Not supported. Specifies the name of the anchor.
pingHTML5list_of_URLsSpecifies a space-separated list of URLs for the specified URL, when the link is followed, the browser will send a ping request (backend). Usually used for tracking
referrerpolicyno-referrer
no-referrer-when-downgrade
origin
origin-when-cross-origin
unsafe-url
Specifies the specific push type
relalternate
author
bookmark
help
license
next
nofollow
noreferrer
prefetch
prev
search
tag
Specifies the relationship between the current document and the target URL. Used only when the href attribute exists.
revtextHTML5 Not supported. Specifies the relationship between the target URL and the current document.
shapedefault
rect
circle
poly
HTML5 Not supported. Specifies the shape of the link.
target_blank
 _parent
 _self
 _top
framename
Specifies where to open the target URL. Used only when the href attribute exists.
type HTML5MIME_typeSpecifies the MIME type of the target URL. Used only when the href attribute exists.
Note: MIME = Multipurpose Internet Mail Extensions.

Global attributes

Support for the <a> tag Global attributes of HTML.

Event attributes

Support for the <a> tag HTML event attributes.

Online Examples

Image Links  This example demonstrates how to use image links.

Link to a specified location within the current page This example demonstrates how to use bookmarks

Break Out of Frames  This example demonstrates how to break out of frames, if your page is fixed within a frame.

Creating an email link This example demonstrates how to link to an email. (This example will only work after installing an email client program.)

Creating an email link 2  This example demonstrates a more complex email link.

Creating a phone link This example demonstrates creating a link that can make a phone call.

Related Articles

HTML Tutorial:HTML Links

HTML DOM Reference Manual: Anchor Object