HTML <a> hrefAttributes

HTML a 标签参考手册HTML <a> Tag

Examples

The href attribute specifies the target URL of the link:

<p>Absolute URL: <a href="../index.html">Example</a></p>
<p>Relative URL: <a href="tag_a.php.html">a tag</a></p>

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the href attribute.


Definition and Usage

The href attribute of the <a> tag is used to specify the URL of the hyperlink target.

If the href attribute is not specified, the <a> tag is not a link.


Difference Between HTML 4.01 and HTML5

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


Syntax

<a href="URL.html">

Attribute Values

Value Description
URL The URL of the hyperlink. Possible values:
  • Absolute URL - points to another site (e.g. href="http://www.example.com/index.htm")
  • Relative URL - points to a file on the site (href="index.htm")
  • Anchor URL - points to an anchor in the page (href="#top")


实例

More Examples

Using Anchor URL
How to use an anchor URL with id (the name attribute is not supported in HTML5).


HTML a 标签参考手册HTML <a> Tag

Other Extensions