Link — an HTML hyperlink

Inherits from

Node, Element


HTML links are created with <a>, <area>, and <link> elements. <a> tags are used in the body of a document to create hyperlinks. <area> tags are a rarely used feature for creating “image maps.” <link> tags are used in the <head> of a document to refer to external resources such as stylesheets and icons. The <a> and <area> elements have the same representation in JavaScript. <link> elements have a somewhat different JavaScript representation, but, for convenience, these two types of links are documented together on this page.

When a Link object that represents an <a> element is used as a string, it returns the value of its href property.


In addition to the properties listed here, a Link object also has properties that reflect the underlying HTML attributes: hreflang, media, ping, rel, sizes, target, and type. Note that the URL decomposition properties (such as host and pathname) that return portions of the link’s href are only defined for <a> and <area> elements, not for <link> elements, and that the sheet, disabled, and relList properties are only defined for <link> elements that refer to stylesheets.

boolean disabled

For <link> elements that refer to stylesheets, this property controls whether the stylesheet is applied to the document or not.

string hash

Specifies the fragment identifier of href, including the leading hash (#) mark—for example, “#results”.

string host

Specifies the hostname and port portions of href ...

Get JavaScript: The Definitive Guide, 6th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.