HTML Dog
Skip to navigation

HTML Tag: link

Defines a link to an external resource. It is most commonly used to link a CSS file to an HTML document.

When used, link must appear inside the head element (unless used with itemprop attribute).

Required Attributes

Attribute Description Possible values
href The location of the resource. URL.

Optional Attributes

Attribute Description Possible values
rel The relationship between the document and the linked resource. Required if an itemprop global attribute is not used. So, in all likelihood, not actually optional.
  • stylesheet: For importing stlyesheets.
  • alternate: An alternative version of the web page.
  • author: Details of the author of the page.
  • help: Help specific to the page.
  • icon: For importing an icon to be associated with the page.
  • license: A copyright license for the current document.
  • next: Indicates that the page is in a sequence and the linked page is the next page in the sequence.
  • prefetch: The linked resource should be cached.
  • prev: Indicates that the page is in a sequence and the linked page is the previous page in the sequence.
  • search: A search facility that can be used to search the current, and related, documents.
type The type of the linked resource. MIME type.
media The media type (or types) that the linked resource should be applied to. Media query, such as screen, print, or screen and max-width:640.
hreflang The language of the target of the link. Language code, such as en (English) or de (German).
sizes Size(s) of the icon, used with rel="icon". [width]x[height] (or a space-separated list of multiple instances of this), eg. 32x64.
crossorigin Used in conjunction with JavaScript to determine how Cross Origin Resource Sharing requests are handled.
  • anonymous
  • use-credentials
Global attributes

Example


<head>
    <title>Links and Bobcats</title>
    <link href="eurasianLynx.css" rel="stylesheet">
    <link href="iberianLynx.css" rel="stylesheet" media="print">
    <link href="canadianLynx.css" rel="stylesheet" media="screen and max-width:640">
    <link href="kitty.ico" rel="icon" sizes="32x32 64x64">
    <link href="/about/" rel="author">
    <link href="Felis.html" rel="prev">
    <link href="Leopardus.html" rel="next">
</head>