CKTIS / HTML
The link element — document resource relationships
The `link` element describes a relationship between an HTML document and another resource, such as a CSS stylesheet. `rel` identifies the relationship, and `href` usually supplies the address. It does not create a visible clickable link.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
<link rel="stylesheet" href="styles.css">link creates external resource links or hyperlinks applying to the whole document. rel="stylesheet" attaches a CSS stylesheet. Unlike a, link is not displayed by default and has no link activation behavior.
rel contains unique space-separated keywords. Without a recognized, allowed keyword, it creates no links. The element must have either rel or itemprop, not both, and at least one of href and imagesrcset. When present, href must contain a valid, nonempty URL; a relative address is resolved against the document base URL.
Usually place link in head. It is allowed in body with itemprop, subject to microdata rules, or when every rel keyword is designated body-ok. It is a void element: it contains no content and has no end tag.
media specifies conditions under which the resource applies, while type provides a MIME type hint. Merely referencing a resource does not guarantee that it is applied: behavior depends on the link type. The example uses rel="stylesheet" and a stylesheet stored in a data URL.
Examples
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Link demo</title>
<link rel="stylesheet" href="data:text/css,p%20%7B%20color%3A%20rgb(0%2C%20128%2C%200)%3B%20%7D">
</head>
<body>
<p>Linked CSS</p>
</body>
</html>Result
Linked CSS
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.