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. |
|
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. |
|
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>