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:
#IDorName
Link to an element with the specified id or name attribute within the current page.
http://...
Link to an external web page.
ftp://...
Connection to an FTP server.
mailto:...
Opens the default e-mail client's new e-mail dialog with the specified e-mail address.
file:...
Specifies the location of the file to download.
javascript:...
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="http://www.example.com/" target="_blank">External Link</a>
<br />
<a href="#innerLink">Jump to inner Link</a>
<br />
<a href="mailto:support@example.com">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:
Code
style.css
<head>
    <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
    Some text content
</body>
Did you find this example helpful? yes no

Supported by tags:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content