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

HTML reference manual

HTML tag大全

HTML: <a> href attribute

This article introduces the usage of the <a> href attribute, demonstrates how to use the <a> href attribute online, browser compatibility, syntax definition, and detailed information about its attribute values, etc.

HTML <a> tag

Online examples

The href attribute specifies the target address of the link:

<p>Absolute path URL: <a href="//www.oldtoolbag.com/">Basic tutorial website</a></p>
<p>Relative path URL: <a href="/tags/tag-a.html">a 标签</a></p>
Test and see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the href attribute.

Definition and Usage

The href attribute specifies the URL of the page to which the link goes.


If the href attribute does not exist, the <a> tag is not a hyperlink.

HTML 4.01 With HTML5 Differences

In HTML5 In HTML, if the <a> tag does not have an href attribute, it will be A placeholder hyperlink.

Syntax

<a href="URL">

Attribute value

ValueDescription
URLThe URL of a hyperlink. Possible values:
  • Absolute URL - Point to another site (such as href="http://www.example.com/index.htm")

  • Relative URL - Point to a file within the site (href="index.htm")

  • Anchor URL - Point to an anchor in the page (href="#top")

More examples

Using an anchor URL
How to link to an element with a specified ID in a page (HTML5The name attribute is not supported).

HTML <a> tag