W3cubDocs

/Web APIs

HTMLLinkElement

The HTMLLinkElement interface represents reference information for external resources and the relationship of those resources to a document and vice versa (corresponds to <link> element; not to be confused with <a>, which is represented by HTMLAnchorElement). This object inherits all of the properties and methods of the HTMLElement interface.

EventTarget Node Element HTMLElement HTMLLinkElement

Instance properties

Inherits properties from its parent, HTMLElement.

HTMLLinkElement.as

A string representing the type of content being loaded by the HTML link.

HTMLLinkElement.crossOrigin

A string that corresponds to the CORS setting for this link element. See CORS settings attributes for details.

HTMLLinkElement.disabled

A boolean value which represents whether the link is disabled; currently only used with style sheet links.

HTMLLinkElement.fetchPriority Experimental

An optional string representing a hint given to the browser on how it should prioritize fetching of a preload relative to other resources of the same type. If this value is provided, it must be one of the possible permitted values: high to fetch at a higher priority, low to fetch at a lower priority, or auto to indicate no preference (which is the default).

HTMLLinkElement.href

A string representing the URI for the target resource.

HTMLLinkElement.hreflang

A string representing the language code for the linked resource.

HTMLLinkElement.media

A string representing a list of one or more media formats to which the resource applies.

HTMLLinkElement.referrerPolicy

A string that reflects the referrerpolicy HTML attribute indicating which referrer to use.

HTMLLinkElement.rel

A string representing the forward relationship of the linked resource from the document to the resource.

HTMLLinkElement.relList Read only

A DOMTokenList that reflects the rel HTML attribute, as a list of tokens.

HTMLLinkElement.sizes Read only

A DOMTokenList that reflects the sizes HTML attribute, as a list of tokens.

HTMLLinkElement.sheet Read only

Returns the StyleSheet object associated with the given element, or null if there is none.

HTMLLinkElement.type

A string representing the MIME type of the linked resource.

Obsolete properties

HTMLLinkElement.charset Deprecated

A string representing the character encoding for the target resource.

HTMLLinkElement.rev Deprecated

A string representing the reverse relationship of the linked resource from the resource to the document.

Note: Currently the W3C HTML 5.2 spec states that rev is no longer obsolete, whereas the WHATWG living standard still has it labeled obsolete. Until this discrepancy is resolved, you should still assume it is obsolete.

HTMLLinkElement.target Deprecated

A string representing the name of the target frame to which the resource applies.

Instance methods

No specific method; inherits methods from its parent, HTMLElement.

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
HTMLLinkElement 1 12 1 5.5 ≤12.1 1 ≤37 18 4 ≤12.1 1 1.0
as 50 17 56 No 37 10 50 50 56 37 10 5.0
blocking 105 105 No No 91 No 105 105 No 72 No 20.0
charset 1 12 1 6 ≤12.1 1 4.4 18 4 ≤12.1 1 1.0
crossOrigin 34 17 18 No 21 10 37 34 18 21 10 2.0
disabled
1In Chrome and other Blink-based browsers, adding the disabled attribute using JavaScript does not remove the stylesheet from document.styleSheets.
12Since Edge 79, adding the disabled attribute using JavaScript does not remove the stylesheet from document.styleSheets.
1 5.5
≤12.1In Chrome and other Blink-based browsers, adding the disabled attribute using JavaScript does not remove the stylesheet from document.styleSheets.
1
1In Chrome and other Blink-based browsers, adding the disabled attribute using JavaScript does not remove the stylesheet from document.styleSheets.
18In Chrome and other Blink-based browsers, adding the disabled attribute using JavaScript does not remove the stylesheet from document.styleSheets.
4
≤12.1In Chrome and other Blink-based browsers, adding the disabled attribute using JavaScript does not remove the stylesheet from document.styleSheets.
1
1.0In Chrome and other Blink-based browsers, adding the disabled attribute using JavaScript does not remove the stylesheet from document.styleSheets.
fetchPriority 102101–102 102101–102 No No 8887–88 No 102101–102 102101–102 No 70 No 19.0
href 1 12 1 5.5 ≤12.1 1 4.4 18 4 ≤12.1 1 1.0
hreflang 1 12 1 6 ≤12.1 1 4.4 18 4 ≤12.1 1 1.0
imageSizes 73 79 78 No 60 No 73 73 79 52 No 11.0
imageSrcset 73 79 78 No 60 No 73 73 79 52 No 11.0
integrity 45 17 43 No 32 11.1 45 45 43 32 11.3 5.0
media 1 12 1 5.5 ≤12.1 1 4.4 18 4 ≤12.1 1 1.0
referrerPolicy 58 79 50 No 45 14.1 58 58 50 43 14.5 7.0
rel 1 12 1 5.5 ≤12.1 1 4.4 18 4 ≤12.1 1 1.0
relList 50 17 30 No 37 9 50 50 30 37 9 5.0
rev 1 12 1 5.5 ≤12.1 1 4.4 18 4 ≤12.1 1 1.0
sheet 1 12 1 9 15 1 4.4 18 4 14 1 1.0
sizes
15Before Chrome 50, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList.
79 31 No
15Before Opera 37, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList.
6
4.4Before WebView 50, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList.
18Before Chrome 50, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList.
31
14Before Opera 37, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList.
6
1.0Before Samsung Internet 5.0, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList.
target 1 12 1 5.5 ≤12.1 1 4.4 18 4 ≤12.1 1 1.0
type 1 12 1 5.5 ≤12.1 1 4.4 18 4 ≤12.1 1 1.0

See also

  • The HTML element implementing this interface: <link>.

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement