Table of Contents

Class HTMLLinkElement

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

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.

[Value("HTMLLinkElement")]
public class HTMLLinkElement : HTMLElement, LinkStyle
Inheritance
HTMLLinkElement
Implements
Inherited Members

Remarks

-The HTML element implementing this interface: link.

See also on MDN

Constructors

HTMLLinkElement()

public HTMLLinkElement()

Properties

As

The as property of the HTMLLinkElement interface returns a string representing the type of content to be preloaded by a link element.

[Value("as")]
public string As { get; set; }

Property Value

string

A string with the following allowed values: "audio", "document", "embed", "fetch", "font", "image", "object", "script", "style", "track", "video", "worker".

Remarks

The as property must have a value for link elements when rel="preload", or the resource will not be fetched.
It may also be applied to link elements where rel="modulepreload", but if omitted, will default to script.
The property should not be set for other types of link elements, such as rel="prefetch".

This property reflects the value of the as attribute of the <link> HTML element.

See also on MDN

Blocking

The blocking property of the HTMLLinkElement interface is a string indicating that certain operations should be blocked on the fetching of an external resource.

[Value("blocking")]
public DOMTokenList Blocking { get; }

Property Value

DOMTokenList

A string. Must be a space-separated list of blocking tokens listed below indicating the operations that are to be blocked:

Remarks

It reflects the blocking attribute of the link element.

-Blocking
-Blocking

See also on MDN

Charset

[Value("charset")]
public string Charset { get; set; }

Property Value

string

CrossOrigin

The crossOrigin property of the HTMLLinkElement interface specifies the Cross-Origin Resource Sharing ({{Glossary("CORS")}}) setting to use when retrieving the resource.

[Value("crossOrigin")]
public string? CrossOrigin { get; set; }

Property Value

string

A string of a keyword specifying the CORS mode to use when fetching the resource. Possible values are:If the crossOrigin property is specified with any other value, it is the same as specifying as the anonymous.If the crossOrigin property is not specified, the resource is fetched without CORS (the no-cors {{domxref("Request.mode", "mode", "", "nocode")}} and the same-origin {{domxref("Request.credentials", "credentials", "", "nocode")}} mode).

Remarks

Disabled

The disabled property of the HTMLLinkElement interface is a boolean value that represents whether the link is disabled. It only has an effect with style sheet links (rel property set to stylesheet).

[Value("disabled")]
public bool Disabled { get; set; }

Property Value

bool

A boolean.

Remarks

If disabled attribute is specified in the HTML when it is loaded, the stylesheet will not be loaded during page load. Instead, the stylesheet will be loaded only when the disabled property is set to false or removed. Setting the disabled property using JavaScript causes the stylesheet to be removed from the document's Document.StyleSheets list.

It reflects the disabled attribute of the link element.

-Integrity
-Subresource Integrity

See also on MDN

FetchPriority

The fetchPriority property of the HTMLLinkElement interface represents a hint to the browser indicating how it should prioritize fetching a particular resource relative to other resources of the same type.
It reflects the fetchpriority attribute of the corresponding link element.

[Value("fetchPriority")]
public string FetchPriority { get; set; }

Property Value

string

A string representing the priority hint.
Possible values are:

Remarks

The property allows a developer to signal that fetching a particular resource early in the loading process has more or less impact on user experience than a browser can reasonably infer when assigning an internal priority, in particular when preloading resources.
This in turn allows the browser to increase or decrease the priority, and potentially load the resource earlier or later than it would otherwise.
The property should be used sparingly, as excessive or incorrect prioritization can degrade performance.

The fetch priority can be used to complement preloading, allowing a developer to boost the priority of a resource ahead of less-impactful resources that are by default preloaded with a higher priority.
For example, if a particular image significantly contributes to the website's Largest Contentful Paint (LCP) it might be set to be preloaded and with a high fetch priority.

Note that both the internal priority of any fetch operation, and the impact of fetchPriority on the priority, are entirely browser dependent.

-FetchPriority
-FetchPriority
-HTTP Link header
-Optimize resource loading with the Fetch Priority API for information about how this API affects priorities on Chrome.

See also on MDN

Href

The href property of the HTMLLinkElement interface contains a string that is the URL associated with the link.

[Value("href")]
public string Href { get; set; }

Property Value

string

A string that contains a URL, or the empty string ("") if there is no href element.

Remarks

It reflects the href attribute of the link element. If the element does not have an href attribute, then this property's value is the empty string ("").

NOTE

Every <link> element must contain either one or both of the href or imagesrcset attributes. This means, for each valid <link>, either this property or ImageSrcset will not be empty.

-ImageSrcset property
-HTMLAnchorElement.Href property

See also on MDN

Hreflang

The hreflang property of the HTMLLinkElement interface is used to indicate the language and the geographical targeting of a page. This hint can be used by browsers to select the more appropriate page or to improve {{Glossary("SEO")}}.

[Value("hreflang")]
public string Hreflang { get; set; }

Property Value

string

A string that contains a language tag, or the empty string ("") if there is no hreflang attribute.

Remarks

It reflects the hreflang attribute of the link element and is the empty string ("") if there is no hreflang attribute.

-Hreflang property

See also on MDN

ImageSizes

The imageSizes property of the HTMLLinkElement interface indicates the size and conditions for the preloaded images defined by the ImageSrcset property. It reflects the value of the {{htmlelement("link")}} element's imagesizes attribute. This property can retrieve or set the imagesizes attribute value.

[Value("imageSizes")]
public string ImageSizes { get; set; }

Property Value

string

A string composed of comma-separated source sizes, or the empty string "" if unspecified.

Remarks

The <link> element's imagesizes attribute is the same as the img element's sizes attribute: a comma-separated source size list. Each source size includes a media condition, the size of the image as a length, or the keyword auto, which must come first. For more information about the syntax of the sizes attribute, see <img>.

The imagesrcset and imagesizes attributes are only relevant on <link> elements that have both a rel attribute set to preload and the as attribute set to image.

-ImageSrcset
-Sizes
-Media queries
-Using the srcset and sizes attributes

See also on MDN

ImageSrcset

The imageSrcset property of the HTMLLinkElement interface is a string which identifies one or more comma-separated image candidate strings. This property reflects the value of the link element's imagesrcset attribute. This property can retrieved or set the imagesrcset attribute value.

[Value("imageSrcset")]
public string ImageSrcset { get; set; }

Property Value

string

A string composed of a comma-separated list of one or more image candidate strings, or the empty string "" if unspecified..

Remarks

Each image candidate string contains an image URL and an optional width and/or pixel density descriptor indicating the conditions under which that candidate image should be used.

For HTML link elements with rel="preload" and as="image" set, the imagesrcset attribute has similar syntax and semantics as the img element's srcset attribute, which indicates to preload the appropriate resource used by an <img> element with corresponding values for its srcset and sizes attributes.

If the imageSrcset property includes width descriptors, the ImageSizes property must be non-null, or the imageSrcset value will be ignored.

-ImageSizes
-Srcset
-Speculative loading
-Responsive images

See also on MDN

Integrity

The integrity property of the HTMLLinkElement interface is a string containing inline metadata that a browser can use to verify that a fetched resource has been delivered without unexpected manipulation.

[Value("integrity")]
public string Integrity { get; set; }

Property Value

string

A string.

Remarks

It reflects the integrity attribute of the link element.

-Integrity
-Subresource Integrity

See also on MDN

Media

The media property of the HTMLLinkElement interface is a string representing a list of one or more media formats to which the resource applies.

[Value("media")]
public string Media { get; set; }

Property Value

string

A string.

Remarks

It reflects the media attribute of the link element.

See also on MDN

ReferrerPolicy

The referrerPolicy property of the HTMLLinkElement interface
reflects the HTML referrerpolicy attribute of the
link element defining which referrer is sent when fetching the
resource.

[Value("referrerPolicy")]
public string ReferrerPolicy { get; set; }

Property Value

string

A string; one of the following:

Remarks

Rel

The rel property of the HTMLLinkElement interface reflects the rel attribute. It is a string containing a space-separated list of link types indicating the relationship between the resource represented by the link element and the current document.

[Value("rel")]
public string Rel { get; set; }

Property Value

string

A string.

Remarks

The most common use of this attribute is to specify a link to an external style sheet:
the property is set to stylesheet, and the href
attribute is set to the URL of an external style sheet to format the page.

-The equivalent property on a and area,
Rel and Rel.
-The very same list but as tokens: RelList

See also on MDN

RelList

The relList read-only property of the HTMLLinkElement interface reflects the rel attribute. It is a live DOMTokenList containing the set of link types indicating the relationship between the resource represented by the {{HTMLElement("link")}} element and the current document.

[Value("relList")]
public DOMTokenList RelList { get; }

Property Value

DOMTokenList

A live DOMTokenList of strings.

Remarks

The property itself is read-only, meaning you can not substitute the
DOMTokenList by another one, but the content of the returned list can be
changed.

-The equivalent property on a and area,
RelList and RelList.
-The very same list but as a space-separated tokens in a string:
Rel

See also on MDN

Rev

[Value("rev")]
public string Rev { get; set; }

Property Value

string

Sizes

The sizes read-only property of the HTMLLinkElement interfaces defines the sizes of the icons for visual media contained in the resource. It reflects the {{HTMLElement("link")}} element's sizes attribute, which takes a list of space-separated sizes, each in the format <width in pixels>x<height in pixels>, or the keyword any.

[Value("sizes")]
public DOMTokenList Sizes { get; }

Property Value

DOMTokenList

A DOMTokenList

Remarks

It is only relevant if the Rel is icon or a non-standard type like apple-touch-icon.

-Rel
-RelList
-Type
-Href
-link
-rel attribute

See also on MDN

Target

[Value("target")]
public string Target { get; set; }

Property Value

string

Type

The type property of the HTMLLinkElement interface is a string that reflects the {{glossary("MIME type")}} of the linked resource.

[Value("type")]
public string Type { get; set; }

Property Value

string

A string, which must be a valid MIME type string.

Remarks

It reflects the type attribute of the link element.

See also on MDN