This website uses cookies

We use cookies to personalize content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you've provided to them or that they've collected from your use of their services. Please read more at our privacy policy page.



HTML <link> Tag

The <link> tag sets the relationship between the current document and the external resource. It is used generally to link to the external CSS stylesheet.

Syntax

The <link> tag is an empty element; it contains only attributes. The tag is always nested inside the <head> tag (generally before the closing </head> tag), and it can be used many times.

In XHTML the closing tag (</link>) is required.

Example

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="style.css">
  </head>
  <body>
    <h1> The appearance of the header is determined by the CSS styles specified in the external file. </h1>
    <p> The appearance of the paragraph is determined by the CSS styles specified in the external file. </p>
  </body>
</html>

Result

Attributes

Attribute Value Description
charset char_encoding Defines the coding of the linked document.
Not supported in HTML5.
href URL Defines the URL of the external file.
hreflang language_code Defines the text language of the linked document.
media media_query Defines the device, for which the styles will be applied.
rel alternate
archives
author
bookmark
external
first
help
icon
last
license
next
nofollow
noreferrer
pingback
prefetch
prev
search
sidebar
stylesheet
tag
up
Defines the relationship between the current document and the linked file.
rev reversed relationship Defines the relationship between the current and linked documents.
Not supported in HTML5.
sizes HeightxWeight Sets the size of the associated icons. Used only with rel = "icon".
target Defines how the link should be opened.
_blank In a new window.
_self In the current window.
_top To the full width of the window.
_parent In the parent frame.
frame_name In the frame.
Not supported in HTML5.
type media_type Defines the MIME-type (specification for network transfer of various types of files) of the linked document.

The <link> tag also supports Global Attributes and the Event Attributes.

Browser support