--- title: HTMLLinkElement slug: Web/API/HTMLLinkElement translation_of: Web/API/HTMLLinkElement ---
{{ APIRef("HTML DOM") }}

Интерфейс HTMLLinkElement представляет справочную информацию для внешних ресурсов и отношение этих ресурсов к документу и наоборот (соответствует элементу <link>; не путать с <a>, который представлен элементом HTMLAnchorElement). Этот объект наследует все свойства и методы интерфейса {{domxref("HTMLElement")}}.

{{InheritanceDiagram(600, 120)}}

Свойства

Наследует свойства от своего родителя, {{domxref("HTMLElement")}}, и {{domxref("LinkStyle")}}.

{{domxref("HTMLLinkElement.as")}}
Это {{domxref("DOMString")}} представляющий тип контента загружаемый по HTML ссылке.
{{domxref("HTMLLinkElement.crossOrigin")}} {{experimental_inline}}
Is a {{domxref("DOMString")}} that corresponds to the CORS setting for this link element. See CORS settings attributes for details.
{{domxref("HTMLLinkElement.disabled")}}
Is a Boolean which represents whether the link is disabled; currently only used with style sheet links.
{{domxref("HTMLLinkElement.href")}}
Is a {{domxref("DOMString")}} representing the URI for the target resource.
{{domxref("HTMLLinkElement.hreflang")}}
Is a {{domxref("DOMString")}} representing the language code for the linked resource.
{{domxref("HTMLLinkElement.media")}}
Is a {{domxref("DOMString")}} representing a list of one or more media formats to which the resource applies.
{{domxref("HTMLLinkElement.referrerPolicy")}} {{experimental_inline}}
Is a {{domxref("DOMString")}} that reflects the {{htmlattrxref("referrerpolicy", "link")}} HTML attribute indicating which referrer to use.
{{domxref("HTMLLinkElement.rel")}}
Is a {{domxref("DOMString")}} representing the forward relationship of the linked resource from the document to the resource.
{{domxref("HTMLLinkElement.relList")}} {{readonlyInline}}
Is a {{domxref("DOMTokenList")}} that reflects the {{htmlattrxref("rel", "link")}} HTML attribute, as a list of tokens.
{{domxref("HTMLLinkElement.sizes")}} {{readonlyInline}}
Is a {{domxref("DOMSettableTokenList")}} that reflects the {{htmlattrxref("sizes", "link")}} HTML attribute, as a list of tokens.
{{domxref("LinkStyle.sheet")}} {{readonlyInline}}
Returns the {{domxref("StyleSheet")}} object associated with the given element, or null if there is none.
{{domxref("HTMLLinkElement.type")}}
Is a {{domxref("DOMString")}} representing the MIME type of the linked resource.

Устаревшие свойства

{{domxref("HTMLLinkElement.charset")}} {{obsolete_inline}}
Is a {{domxref("DOMString")}} representing the character encoding for the target resource.
{{domxref("HTMLLinkElement.rev")}} {{obsolete_inline}}
Is a {{domxref("DOMString")}} representing the reverse relationship of the linked resource from the resource to the document.
Примечание: 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.
{{domxref("HTMLLinkElement.target")}} {{obsolete_inline}}
Is a {{domxref("DOMString")}} representing the name of the target frame to which the resource applies.

Методы

Не имеет методов; наследует методы от своего родителя, {{domxref("HTMLElement")}}, и {{domxref("LinkStyle")}}.

Спецификации

Specification Status Comment
{{SpecName("Preload")}} {{Spec2("Preload")}} Defines <link rel="preload">, and the as property. Note that currently Firefox only supports preloading of cacheable resources.
{{SpecName('HTML WHATWG', "#htmllinkelement", "HTMLLinkElement")}} {{Spec2('HTML WHATWG')}} Adds the following properties: crossOrigin, referrerPolicy, and as.
{{SpecName('HTML5.1', "document-metadata.html#the-link-element", "HTMLLinkElement")}} {{Spec2('HTML5.1')}}
{{SpecName('HTML5 W3C', "document-metadata.html#the-link-element", "HTMLLinkElement")}} {{Spec2('HTML5 W3C')}} The following properties are now obsolete: charset, rev, and shape.
The following properties have been added: relList, and sizes.
{{SpecName('DOM2 HTML', 'html.html#ID-35143001', 'HTMLLinkElement')}} {{Spec2('DOM2 HTML')}} Added a second inheritence, the {{domxref("LinkStyle")}} interface.
{{SpecName('DOM1', 'level-one-html.html#ID-35143001', 'HTMLLinkElement')}} {{Spec2('DOM1')}} Initial definition.

Совместимость браузера

{{Compat("api.HTMLLinkElement")}}

Смотрите также