HTML <link>
Tag
HTML
The <link>
tag determines the relationship between the document and the resource.
HTML <link>
Tag
The <link>
element defines relationships between the current document and an external resource.
The <link>
element is commonly used to link to stylesheets, but is also used to link site icons.
Element Attributes
Attribute | Value | Description |
---|---|---|
crossorigin |
anonymous use-credentials |
This specifies whether CORS must be used when fetching resources. |
href |
url | This specifies the location of the linked resource. |
hreflang |
language_code | This specifies the language of the linked resource. |
media |
media_query | This attribute specifies the media that the linked resource applies to. |
referrerpolicy |
no-referrer no-referrer-when-downgrade origin origin-when-cross-origin unsafe-url |
It specifies which referrer to use when fetching resources. |
rel |
alternate author dns-prefetch help icon license next pingback preconnect prefetch preload prerender prev search stylesheet |
Required. This specifies the relationship between the linked document and the current document. |
sizes |
height X width any |
This specifies the size of the linked resource. Only if rel="icon" |
title |
It specifies a default or an alternate stylesheet. | |
type |
media_type | It specifies the media type of the linked document. |
Global attributes
Global attributes may be applied on all elements, although some elements may have no effect on them.
<accesskey>
,
<class>
,
<contenteditable>
,
<contextmenu>
,
<data-*>
,
<dir>
,
<draggable>
,
<dropzone>
,
<hidden>
,
<id>
,
<lang>
,
<spellcheck>
,
<style>
,
<tabindex>
,
<title>
,
<translate>
.
Global Event Handler Attributes
Global Event Handler attributes may be applied on all elements, although some elements may have no effect on them.
<onabort>
,
<onautocomplete>
,
<onautocompleteerror>
,
<onblur>
,
<oncancel>
,
<oncanplay>
,
<oncanplaythrough>
,
<onchange>
,
<onclick>
,
<onclose>
,
<oncontextmenu>
,
<oncuechange>
,
<ondblclick>
,
<ondrag>
,
<ondragend>
,
<ondragenter>
,
<ondragleave>
,
<ondragover>
,
<ondragstart>
,
<ondrop>
,
<ondurationchange>
,
<onemptied>
,
<onended>
,
<onerror>
,
<onfocus>
,
<oninput>
,
<oninvalid>
,
<onkeydown>
,
<onkeypress>
,
<onkeyup>
,
<onload>
,
<onloadeddata>
,
<onloadedmetadata>
,
<onloadstart>
,
<onmousedown>
,
<onmouseenter>
,
<onmouseleave>
,
<onmousemove>
,
<onmouseout>
,
<onmouseover>
,
<onmouseup>
,
<onmousewheel>
,
<onpause>
,
<onplay>
,
<onplaying>
,
<onprogress>
,
<onratechange>
,
<onreset>
,
<onresize>
,
<onscroll>
,
<onseeked>
,
<onseeking>
,
<onselect>
,
<onshow>
,
<onsort>
,
<onstalled>
,
<onsubmit>
,
<onsuspend>
,
<ontimeupdate>
,
<ontoggle>
,
<onvolumechange>
,
<onwaiting>
.
Learning with HTML Editor "Try it Now"
You can edit the HTML code and view the result using online editor.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML link tag example</title>
<link rel="stylesheet" href="externals_style.css">
</head>
<body>
<h1>HTML link tag example.</h1>
<h2>The link tag is used to specify the relationship between current page and external resource.</h2>
<p>External style sheet can be applied to current page using link tag</p>
</body>
</html>
Click on the "Try it Now" button to see how it works.