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.
Properties
Inherits properties from its parent, HTMLElement.
HTMLLinkElement.as-
Is a
DOMStringrepresenting the type of content being loaded by the HTML link. -
HTMLLinkElement.crossOrigin -
Is a
DOMStringthat corresponds to the CORS setting for this link element. See CORS settings attributes for details. HTMLLinkElement.disabled-
Is a
Booleanwhich represents whether the link is disabled; currently only used with style sheet links. HTMLLinkElement.href-
Is a
DOMStringrepresenting the URI for the target resource. HTMLLinkElement.hreflang-
Is a
DOMStringrepresenting the language code for the linked resource. HTMLLinkElement.media-
Is a
DOMStringrepresenting a list of one or more media formats to which the resource applies. -
HTMLLinkElement.referrerPolicy -
Is a
DOMStringthat reflects thereferrerpolicyHTML attribute indicating which referrer to use. HTMLLinkElement.rel-
Is a
DOMStringrepresenting the forward relationship of the linked resource from the document to the resource. -
HTMLLinkElement.relListRead only -
Is a
DOMTokenListthat reflects therelHTML attribute, as a list of tokens. -
HTMLLinkElement.sizesRead only -
Is a
DOMSettableTokenListthat reflects thesizesHTML attribute, as a list of tokens. -
HTMLLinkElement.sheetRead only -
Returns the
StyleSheetobject associated with the given element, ornullif there is none. HTMLLinkElement.type-
Is a
DOMStringrepresenting the MIME type of the linked resource.
Obsolete properties
-
HTMLLinkElement.charset -
Is a
DOMStringrepresenting the character encoding for the target resource. -
HTMLLinkElement.rev -
Is a
DOMStringrepresenting the reverse relationship of the linked resource from the resource to the document.Note: Currently the W3C HTML 5.2 spec states that
revis 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 -
Is a
DOMStringrepresenting the name of the target frame to which the resource applies.
Methods
No specific method; inherits methods from its parent, HTMLElement.
Specifications
| Specification |
|---|
| HTML Standard (HTML) # htmllinkelement |
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 |
3 |
1 |
18 |
4 |
≤12.1 |
1 |
1.0 |
as |
50 |
17 |
56 |
No |
37 |
10 |
50 |
50 |
56 |
37 |
10 |
5.0 |
charset |
1 |
12 |
1 |
6 |
≤12.1 |
3 |
1 |
18 |
4 |
≤12.1 |
1 |
1.0 |
crossOrigin |
34 |
17 |
18 |
No |
21 |
10 |
37 |
34 |
18 |
21 |
10 |
2.0 |
disabled |
1
In Chrome and other Blink-based browsers, adding the
disabled attribute using JavaScript does not remove the stylesheet from document.styleSheets. |
12
Since Edge 79, adding the
disabled attribute using JavaScript does not remove the stylesheet from document.styleSheets. |
1 |
5.5 |
≤12.1
In Chrome and other Blink-based browsers, adding the
disabled attribute using JavaScript does not remove the stylesheet from document.styleSheets. |
3 |
1
In Chrome and other Blink-based browsers, adding the
disabled attribute using JavaScript does not remove the stylesheet from document.styleSheets. |
18
In Chrome and other Blink-based browsers, adding the
disabled attribute using JavaScript does not remove the stylesheet from document.styleSheets. |
4 |
≤12.1
In Chrome and other Blink-based browsers, adding the
disabled attribute using JavaScript does not remove the stylesheet from document.styleSheets. |
1 |
1.0
In Chrome and other Blink-based browsers, adding the
disabled attribute using JavaScript does not remove the stylesheet from document.styleSheets. |
href |
1 |
12 |
1 |
5.5 |
≤12.1 |
3 |
1 |
18 |
4 |
≤12.1 |
1 |
1.0 |
hreflang |
1 |
12 |
1 |
6 |
≤12.1 |
3 |
1 |
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 |
3 |
1 |
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 |
3 |
1 |
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 |
3 |
1 |
18 |
4 |
≤12.1 |
1 |
1.0 |
sizes |
15
Before Chrome 50, this property returned the deprecated child
DOMSettableTokenList instead of DOMTokenList. |
79 |
31 |
No |
15
Before Opera 37, this property returned the deprecated child
DOMSettableTokenList instead of DOMTokenList. |
6 |
≤37
Before WebView 50, this property returned the deprecated child
DOMSettableTokenList instead of DOMTokenList. |
18
Before Chrome 50, this property returned the deprecated child
DOMSettableTokenList instead of DOMTokenList. |
31 |
14
Before Opera 37, this property returned the deprecated child
DOMSettableTokenList instead of DOMTokenList. |
6 |
1.0
Before Samsung Internet 5.0, this property returned the deprecated child
DOMSettableTokenList instead of DOMTokenList. |
target |
1 |
12 |
1 |
5.5 |
≤12.1 |
3 |
1 |
18 |
4 |
≤12.1 |
1 |
1.0 |
type |
1 |
12 |
1 |
5.5 |
≤12.1 |
3 |
1 |
18 |
4 |
≤12.1 |
1 |
1.0 |
sheet |
1 |
12 |
1 |
9 |
15 |
1 |
1 |
18 |
4 |
14 |
1 |
1.0 |
See also
- The HTML element implementing this interface:
<link>.
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement