Loading...
HTML <link> Tag

HTML <link> Tag

In this tutorial, we will learn about link tag in HTML with the help of examples.


Link tag <link> is used to link external document with the current document.

Note : The <link> tag is mostly used to link external style sheets.

Syntax

<link>........</link>

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Link Tag</title>
    <link rel = "stylesheet" href = "../sample.css"/>
  </head>
  <body>
    <p>In this paragraph we have link a CSS</p>
  </body>
</html>

Sample.css

body {
  background-color : yellow;
}

Output

In this paragraph we have link a CSS


Specific Attribute

Attribute Value Description
charset charset It defines the character encoding of the linked document
crossorigin anonymous
user-credentials
It specifies how the element handles cross-origin requests
href URL It specifies the URL of the resource document
hreflang language Language code of the destination URL
media screen
tty
tv
projection
handheld
print
braille
aural
all
It specifies the device the document will be displayed on
referrerpolicy no-referrer
no-referrer-when-downgrade
orgin
origin-when-cross-origin
unsafe-url
rel alternate
appendix
bookmark
chapter
contents
copyright
glossary
help
home
index
next
prev
section
start
stylesheet
subsection
It describes the relationship between the current document and the destination URL
rev alternate
appendix
bookmark
chapter
contents
copyright
glossary
help
home
index
next
prev
section
start
stylesheet
subsection
It describes a reverse between the curent document and the destination URL
sizes Height*Width
any
It specifies the size of the linked resource
target _blank
_self
_top
_parent
It specifies the target frame to load the page info
title text It defines a preferred or an alternate stylesheet
type mimetype The MIMEtype of the content at the link destination

Global Attribute

Link Tag support all the global attributes of HTML.


Event Attribute

Link Tag support all the event attributes of HTML.


Next Tutorial

We hope that this tutorial helped you develop better understanding of the concept of <link> tag in HTML.

Keep Learning : )

In the next tutorial, you'll learn about HTML <main> Tag.

- Related Topics