Area href Property

Area Object Reference Area Object


Change the URL of a link in an area:

document.getElementById("venus").href = "sun.htm";

Try it yourself »

Definition and Usage

The href property sets or returns the value of the href attribute of an area.

The href attribute specifies the destination of a link in an area.

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The href property is supported in all major browsers.


Return the href property:


Set the href property:


Property Values

Value Description
URL Specifies the hyperlink target for the area.

Possible values:
  • An absolute URL - points to another web site (like href="")
  • A relative URL - points to a file within a web site (like href="sun.htm")
  • Link to an element with a specified id within the page (like href="#top")
  • Other protocols (like https://, ftp://, mailto:, file:, etc..)
  • A script (like href="javascript:alert('Hello');")

Technical Details

Return Value: A String, representing the URL of the link. Returns the entire URL, including the protocol (like http://)

More Examples


Get the URL of a link in an area:

var x = document.getElementById("venus").href;

The result of x will be:

Try it yourself »


Change the URL of a link in an area to an absolute URL:

document.getElementById("venus").href = "";

Try it yourself »

Related Pages

HTML reference: HTML <area> href attribute

Area Object Reference Area Object


Color Picker