HTML <link> tag

Updated: 10/11/2017 by Computer Hope

HTML link tagWhen writing in HTML, the <link> tag is used to create 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 file to adjust the layout and appearance of a website. The following sections contain information about this tag, including an example of its code, as well as related attributes and browser compatibility.

Example code

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

Attributes

Within an HTML tag, an attribute dictates certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. The following table shows all of the current unique HTML attributes for the <link> tag, as well as a description of each.

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

A deprecated attribute is one that may function currently but is not supported in going forward. While the attribute may work with the current version of HTML, it will eventually be phased out. It is better to avoid using these attributes to help future-proof your website.

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

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

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