HTML link Tag

  • HTML <link> tag is used to load an external stylesheets into HTML document. Usually the <link> tag is represent relationship between a current document and one or more external CSS stylesheets.

Example

link_tag_style.css
/* CSS Document */
p {
  color: #c7254e;
  font-size: 15px;
  font-family: 'Arial', Helvetica, sans-serif;
}
<!DOCTYPE html>
<html>
<head>
  <title>HTML link tag</title>
  <link rel="stylesheet" type="text/css" href="link_tag_style.css" />
</head>
<body>
  <p>First sentence</p>
  <p>Second sentence</p>
</body>
</html>

Run it...   »

<link> Tag Attributes

HTML <link> tag support following specific attributes.

Attributes Value Description
crossorigin anonymous
use-credentials
Specify how to handle CORS.
anonymous Cross-origin request perform without any credential.
use-credentials Cross-origin request perform with sent credential.
href URL Specify the URL of the external linked resource.
hreflang lang_code Specify the language of the text in the external linked resource.
media all
print
screen
speech
Specify the media device, external resource will be displayed for that device.
The default value is all.
rel alternate
author
canonical
help
icon
license
manifest
next
pingback
prefetch
preload
prerender
prev
search
shortlink
stylesheet
Required. Specify the relationship of the external linked document.
sizes HEIGHTxWIDTH
any
Specify the size of icons (favicons) that are linked externally. Example: sizes="any" (any size)
sizes="16x16" (1 size)
sizes="16x16 32x32 64x64" (3 sizes)
type MIME_type Specify the mime type of the external linked document.
Following attribute has been removed in HTML5.
charset charset Specify the character encoding of the external linked document.
rev alternate
author
canonical
help
icon
license
manifest
next
pingback
prefetch
preload
prerender
prev
search
shortlink
stylesheet
Specify the reverse relationship of the external linked resource to current document.
target _blank
_parent
_self
_top
Specify the location where to load external linked document.

Global Attributes

HTML <link> tag does not support any global attributes.

Event Attributes

HTML <link> tag does not support any event attributes.

Browser Compatibility

  • Google Chrome
    Yes
  • Mozilla Firefox
    Yes
  • Microsoft Edge
    Yes
  • Opera
    Yes
  • Safari
    Yes