HTML Tags

HTML <link> Tag

Topic: HTML5 Tags ReferencePrev|Next

Description

The <link> tag defines a link between the current document and an external resource.

The <link> element may only appear in the head section of a document, although it may appear any number of times. It is mostly used in linking style sheets to the HTML document.

The following table summarizes the usages context and the version history of this tag.

Parent: <head>
Content: None. It is an empty element.
Start/End Tag: Start tag: required, End tag: forbidden
Version: HTML 2, 3.2, 4, 4.01, 5

Syntax

The basic syntax of the <link> tag is given with:

HTML:<link rel="link-type" href="URL">
XHTML:<link rel="link-type" href="URL" />

The example below shows the <link> tag in action.

<head>
    <title>HTML Document</title>
    <link rel="stylesheet" href="default.css">
</head>

Tag-Specific Attributes

The following table shows the attributes that are specific to the <link> tag.

Attribute Value Description
charset charset Obsolete Specifies the character encoding of the linked resource.
crossorigin anonymous
use-credentials
Specifies how the element handles cross-origin requests.
href URL Specifies the location of a linked document.
hreflang language-code Specifies the language of the linked document. This attribute may only be used when href is specified.
media media-types Specifies the media which the linked resource applies to. The default value is screen.
rel alternate
author
help
icon
license
next
prefetch
prev
search
stylesheet
tag
Specifies the relationship of the linked resource to the current document. This attribute should be used only if the href attribute is present.
rev link-type Obsolete Describes the relationship of the linked document back to the source document (the opposite of the rel attribute).
sizes HeightxWidth
any
Specifies the size of the icons (for rel="icon").
target _blank
_parent
_self
_top

framename
Obsolete Defines where to open the linked document specified in the href attribute.
type content-type Specifies the content type of the linked document. The most common value is text/css, which indicates a Cascading Style Sheet format.

Global Attributes

Like all other HTML tags, the <link> tag supports the global attributes in HTML5.


Event Attributes

The <link> tag also supports the event attributes in HTML5.


Browser Compatibility

The <link> tag is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 3+
  • Apple Safari 1+
  • Opera 4+

Note: When used for referencing external style sheets, the <link> element is supported in all major browsers, but there's no real support for anything else.


Further Reading

See tutorial on: HTML Style Sheets.

Related tags: <style>.

Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties