link element

If you don't know what an element is or how you must use it, I recommend you read the "HTML tags and attributes" tutorial that you can find in the HTML tutorials section.


The link element provides relational information about the document, like alternative versions, authors, copyright licences, icons, etc.

A link element must have either a rel attribute or an itemprop attribute, but never both. The href attribute is also mandatory.

When the itemprop attribute is absent, this element can only be declared in the head of the document. Otherwise it can be declared elsewhere.


The following example povides information about the document using the link element with different link types.

<!DOCTYPE html>
    <title>Movie "Star wars: A new hope"</title>
    <link rel="license" href="copyright.html">
    <link rel="next" href="the-empire-strikes-back.html">
    <link rel="search" href="movies-search.html">
    <link rel="alternate" hreflang="es" href="es/una-nueva-esperanza.html">
    <link rel="stylesheet" href="default.css">
    <link rel="stylesheet alternate" media="print" href="print.css">
    <link rel="icon" sizes="16x16" href="a-new-hope-16.png">
    <h1>A new hope</h1>
    <p>After the fall of democracy and the rise of the empire, hope has been lost...</p>


Specific attributes


The address (URI) of the linked resource resource. This attribute represents the heart of link, and tells browser where to go when the link is followed.

The presence of this attribute is mandatory. When this attribute is absent or has a value that isn't a valid URI, the element doesn't define a link.


<link rel="stylesheet" href="../styles/default.css">


An enumerated value indicating if the request made to the external server should present CORS credentials or not. The two possible values are (case-insensitive):

  • anonymous: CORS requests for the element will have the "omit credentials" flag set.
  • use-credentials: CORS requests for the element won't have the "omit credentials" flag set.


<link rel="icon" href="" crossorigin="anonymous">


A space-separated list of link types, indicating the meaning that the linked resource has for the current document (the one containing the link).

A link element must have either a rel attribute or an itemprop attribute, but never both.


<link rel="prev" href="article1.html">
<link rel="next" href="article3.html">
<link rel="license" href="copyright.html">
<link rel="alternate" href="spanish-version.html" hreflang="es">


A media query list indicating the media types (and their characteristics) for which the linked resource was designed. For example, a document or resource could be optimized for printing (less color, images and backgrounds), a mobile device or a regular screen. The defaut value is "all".


<link rel="alternate" href="printer-version.html" media="print">


The language that's expected to be used in the linked resource (the one specified in the href attribute).


<link rel="alternate" hreflang="es" href="spanish-version.html">


The content type (or Internet Media Type) that the linked resource is expected to have.


<link rel="icon" href="icon.png" type="image/png">
<link rel="next" href="article2.html" type="text/html">


A space-separated list with sizes for which the linked icon has been designed. Each size can be composed by a string of two integers separated by the letter "x", or by the special keyword "any", which represents all posible sizes (this is ideal for SVG icons). Every value is case-insensitive.

This attribute must only be declared when the rel attribute is present and it has the "icon" value. In any other situation its use is invalid.


<link rel="icon" href="icon.ico" sizes="64x64 32x32 16x16">
<link rel="icon" href="icon.svg" sizes="any">


The character encoding of the target resource.

This attribute has become obsolete in HTML5 and its use is no longer valid. Authors are encouraged to use HTTP Content-Type headers to provide information about character sets in documents and other resources.


<link rel="next" href="article2.html" charset="utf-8">


The meaning of the current document (the one containing the link) for the linked resource.

This attribute became obsolete in HTML5 and its use is no longer valid. Authors are encouraged to replace it with the rel attribute.


<link rev="index" href="article1.html">
<link rev="index" href="article2.html">
<link rev="index" href="article3.html">

Global attributes

For information about global attributes refer to this list of global attributes in HTML5.


Global events

For information about global events refer to this list of global events in HTML5.