You are here: Reference > HTML > attributes > href (a, area, link)

href attribute (a, area, link)

Browser support:
Specifies the location of the destination.
JavaScript page for this attribute: href. You can find other example(s) there.

Possible values:

String that sets the URI of the target.
For internal links, the value of the id or name attributes of the target object can be used as well (href='#jumpto'). If the value is an URL, then it can also be an absolute or relative path. Relative paths are relative to the base URL. The base URL is the location of the current document, but it can be overridden by the base tag.
Some possible values:
Link to an element with the specified id or name attribute within the current page.
Link to an external web page.
Connection to an FTP server.
Opens the default e-mail client's new e-mail dialog with the specified e-mail address.
Specifies the location of the file to download.
The script code to execute.
Default: this attribute has no default value.

Example HTML code 1:

This example illustrates the use of the href attribute:
<a href="" target="_blank">External Link</a>
<br />
<a href="#innerLink">Jump to inner Link</a>
<br />
<a href="">mailto</a>
<br />
<a href="javascript: alert ('click');">anchor with JavaScript</a>
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<span id="innerLink">The inner destination</span>
Did you find this example helpful? yes no

Example HTML code 2:

This example shows how to link a style document into a HTML document:
    <link rel="stylesheet" type="text/css" href="style.css" />
    Some text content
Did you find this example helpful? yes no

Supported by tags:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content