Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Anchor href Property

Anchor href Property

Anchor Object Reference Anchor Object


Definition and Usage

The href property can set or return the value of the href attribute in a link.

The href attribute specifies the URL of the linked resource.

Syntax

Set the href attribute:

anchorObject.href="

URL

"

Return the href attribute:

anchorObject.href

Value Description
URL The URL of the linked resource.

Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the href property.


Example

Example

Returns the value of the href attribute in the link:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>

Runoob Tutorial(runoob.com)

title

head

<body>
<p>
<a id="runoob" href="//www.runoob.com/">

Runoob Tutorial

a

p

<

script

document.write("Returns the href link: "); document.write(document.getElementById('runoob').href);

script

body

html

Try it »


Anchor Object Reference Anchor Object