HTML <link> tag

Updated: 11/13/2018 by Computer Hope
HTML link tag

When writing in HTML (hypertext markup language), the <link> tag creates a link between a web page and an external resource. It is useful for defining a framework for navigation purposes or, more typically, linking a CSS (cascading style sheets) file to adjust the layout and appearance of a website. The following sections contain information about this tag, including an example of its code, and related attributes and browser compatibility.

Tip

If you're attempting to create a hyperlink to another web page or website, see the <a> tag.

Example <link> code

<link rel="stylesheet" type="text/css" href="layout.css">

Attributes

All HTML tags support standard attributes that define the settings of an HTML element. In addition to the standard settings, the <link> tag has the following unique attributes.

Attribute Description
crossorigin Designates how related images are fetched.
href Designates the location of the linked document.
hreflang Designates the language of the text in a linked document.
media Designates device on which a linked document is displayed.
rel Designates the relationship between the current document and a linked one (required).
sizes Designates the size of the linked resource. Only to be used with rel="icon".
type Designates the type of media is contained in a linked resource.

Deprecated attributes

In addition to the above attributes, the <link> tag had the following deprecated attributes.

Attribute Description
charset Designates how a linked documents characters are encoded.
rev Designates the relationship between a linked document and the current one.
target Designates where to load a linked resource.

Compatibility

Edge Internet Explorer Firefox Safari Opera Chrome
All versions All versions All versions All version All versions All versions

Browser, Code, Compatibility, Encode, Icon, URL, Web design terms