GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing html.spec.whatwg.org — HTML Standard
4.6 Links4.6.1 IntroductionLinks are a conceptual construct, created by
For Similarly, for Similarly, for A hyperlink can have one or more hyperlink annotations that modify the processing semantics of that hyperlink. 4.6.2 Links created by
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Link type | Effect on... | body-ok | Has `Link` processing | Brief description | ||
|---|---|---|---|---|---|---|
link | a and area | form | ||||
alternate | Hyperlink | not allowed | · | · | Gives alternate representations of the current document. | |
canonical | Hyperlink | not allowed | · | · | Gives the preferred URL for the current document. | |
author | Hyperlink | not allowed | · | · | Gives a link to the author of the current document or article. | |
bookmark | not allowed | Hyperlink | not allowed | · | · | Gives the permalink for the nearest ancestor section. |
dns-prefetch | External Resource | not allowed | Yes | · | Specifies that the user agent should preemptively perform DNS resolution for the target resource's origin. | |
expect | Internal Resource | not allowed | · | · | Expect an element with the target ID to appear in the current document. | |
external | not allowed | Annotation | · | · | Indicates that the referenced document is not part of the same site as the current document. | |
help | Hyperlink | · | · | Provides a link to context-sensitive help. | ||
icon | External Resource | not allowed | · | · | Imports an icon to represent the current document. | |
manifest | External Resource | not allowed | · | · | Imports or links to an application manifest. [MANIFEST] | |
modulepreload | External Resource | not allowed | Yes | · | Specifies that the user agent must preemptively fetch the module script and store it in the document's module map for later evaluation. Optionally, the module's dependencies can be fetched as well. | |
license | Hyperlink | · | · | Indicates that the main content of the current document is covered by the copyright license described by the referenced document. | ||
next | Hyperlink | · | · | Indicates that the current document is a part of a series, and that the next document in the series is the referenced document. | ||
nofollow | not allowed | Annotation | · | · | Indicates that the current document's original author or publisher does not endorse the referenced document. | |
noopener | not allowed | Annotation | · | · | Creates a top-level traversable with a non-auxiliary browsing
context if the hyperlink would otherwise create one that was auxiliary (i.e., has an
appropriate target attribute value). | |
noreferrer | not allowed | Annotation | · | · | No `Referer` (sic) header will be included.
Additionally, has the same effect as noopener. | |
opener | not allowed | Annotation | · | · | Creates an auxiliary browsing context if the hyperlink would otherwise create
a top-level traversable with a non-auxiliary browsing context (i.e.,
has "_blank" as target
attribute value). | |
pingback | External Resource | not allowed | Yes | · | Gives the address of the pingback server that handles pingbacks to the current document. | |
preconnect | External Resource | not allowed | Yes | Yes | Specifies that the user agent should preemptively connect to the target resource's origin. | |
prefetch | External Resource | not allowed | Yes | · | Specifies that the user agent should preemptively fetch and cache the target resource as it is likely to be required for a followup navigation. | |
preload | External Resource | not allowed | Yes | Yes | Specifies that the user agent must preemptively fetch and cache the target resource for current navigation according to the preload destination given by the as attribute (and the priority associated with the corresponding destination). | |
prev | Hyperlink | · | · | Indicates that the current document is a part of a series, and that the previous document in the series is the referenced document. | ||
privacy-policy | Hyperlink | not allowed | · | · | Gives a link to information about the data collection and usage practices that apply to the current document. | |
search | Hyperlink | · | · | Gives a link to a resource that can be used to search through the current document and its related pages. | ||
stylesheet | External Resource | not allowed | Yes | · | Imports a style sheet. | |
tag | not allowed | Hyperlink | not allowed | · | · | Gives a tag (identified by the given address) that applies to the current document. |
terms-of-service | Hyperlink | not allowed | · | · | Gives a link to information about the agreements between the current document's provider and users who wish to use the current document. | |
alternate"Support in one engine only.
The alternate keyword may be used with link,
a, and area elements.
The meaning of this keyword depends on the values of the other attributes.
link element and the rel
attribute also contains the keyword stylesheetThe alternate keyword modifies the meaning of the stylesheet keyword in the way described for that keyword. The
alternate keyword does not create a link of its own.
Here, a set of link elements provide some style sheets:
<!-- a persistent style sheet -->
< link rel = "stylesheet" href = "default.css" >
<!-- the preferred alternate style sheet -->
< link rel = "stylesheet" href = "green.css" title = "Green styles" >
<!-- some alternate style sheets -->
< link rel = "alternate stylesheet" href = "contrast.css" title = "High contrast" >
< link rel = "alternate stylesheet" href = "big.css" title = "Big fonts" >
< link rel = "alternate stylesheet" href = "wide.css" title = "Wide screen" >
alternate keyword is used with the type attribute set to the value application/rss+xml or the value application/atom+xmlThe keyword creates a hyperlink referencing a syndication feed (though not necessarily syndicating exactly the same content as the current page).
For the purposes of feed autodiscovery, user agents should consider all link
elements in the document with the alternate keyword used and
with their type attribute set to the value application/rss+xml or the value application/atom+xml. If the user agent has the concept of a default
syndication feed, the first such element (in tree order) should be used as the
default.
The following link elements give syndication feeds for a blog:
< link rel = "alternate" type = "application/atom+xml" href = "posts.xml" title = "Cool Stuff Blog" >
< link rel = "alternate" type = "application/atom+xml" href = "posts.xml?category=robots" title = "Cool Stuff Blog: robots category" >
< link rel = "alternate" type = "application/atom+xml" href = "comments.xml" title = "Cool Stuff Blog: Comments" >
Such link elements would be used by user agents engaged in feed autodiscovery,
with the first being the default (where applicable).
The following example offers various different syndication feeds to the user, using
a elements:
< p > You can access the planets database using Atom feeds:</ p >
< ul >
< li >< a href = "recently-visited-planets.xml" rel = "alternate" type = "application/atom+xml" > Recently Visited Planets</ a ></ li >
< li >< a href = "known-bad-planets.xml" rel = "alternate" type = "application/atom+xml" > Known Bad Planets</ a ></ li >
< li >< a href = "unexplored-planets.xml" rel = "alternate" type = "application/atom+xml" > Unexplored Planets</ a ></ li >
</ ul >
These links would not be used in feed autodiscovery.
The keyword creates a hyperlink referencing an alternate representation of the current document.
The nature of the referenced document is given by the hreflang, and type attributes.
If the alternate keyword is used with the hreflang attribute, and that attribute's value differs
from the document element's language, it indicates that the referenced
document is a translation.
If the alternate keyword is used with the type attribute, it indicates that the referenced document is
a reformulation of the current document in the specified format.
The hreflang and type attributes can be combined when specified with the alternate keyword.
The following example shows how you can specify versions of the page that use alternative formats, are aimed at other languages, and that are intended for other media:
< link rel = alternate href = "/en/html" hreflang = en type = text/html title = "English HTML" >
< link rel = alternate href = "/fr/html" hreflang = fr type = text/html title = "French HTML" >
< link rel = alternate href = "/en/html/print" hreflang = en type = text/html media = print title = "English HTML (for printing)" >
< link rel = alternate href = "/fr/html/print" hreflang = fr type = text/html media = print title = "French HTML (for printing)" >
< link rel = alternate href = "/en/pdf" hreflang = en type = application/pdf title = "English PDF" >
< link rel = alternate href = "/fr/pdf" hreflang = fr type = application/pdf title = "French PDF" >
This relationship is transitive — that is, if a document links to two other documents
with the link type "alternate", then, in addition to implying
that those documents are alternative representations of the first document, it is also implying
that those two documents are alternative representations of each other.
author"The author keyword may be used with link,
a, and area elements. This keyword creates a hyperlink.
For a and area elements, the author
keyword indicates that the referenced document provides further information about the author of
the nearest article element ancestor of the element defining the hyperlink, if there
is one, or of the page as a whole, otherwise.
For link elements, the author keyword indicates
that the referenced document provides further information about the author for the page as a
whole.
The "referenced document" can be, and often is, a mailto: URL giving the email address of the author. [MAILTO]
Synonyms: For historical reasons, user agents must also treat
link, a, and area elements that have a rev attribute with the value "made" as having the author keyword specified as a link relationship.
bookmark"The bookmark keyword may be used with a and
area elements. This keyword creates a hyperlink.
The bookmark keyword gives a permalink for the nearest
ancestor article element of the linking element in question, or of
the section the linking element is most closely associated with, if
there are no ancestor article elements.
The following snippet has three permalinks. A user agent could determine which permalink applies to which part of the spec by looking at where the permalinks are given.
...
< body >
< h1 > Example of permalinks</ h1 >
< div id = "a" >
< h2 > First example</ h2 >
< p >< a href = "a.html" rel = "bookmark" > This permalink applies to
only the content from the first H2 to the second H2</ a > . The DIV isn't
exactly that section, but it roughly corresponds to it.</ p >
</ div >
< h2 > Second example</ h2 >
< article id = "b" >
< p >< a href = "b.html" rel = "bookmark" > This permalink applies to
the outer ARTICLE element</ a > (which could be, e.g., a blog post).</ p >
< article id = "c" >
< p >< a href = "c.html" rel = "bookmark" > This permalink applies to
the inner ARTICLE element</ a > (which could be, e.g., a blog comment).</ p >
</ article >
</ article >
</ body >
...
canonical"The canonical keyword may be used with link
element. This keyword creates a hyperlink.
The canonical keyword indicates that URL given by the href attribute is the preferred URL for the current document. That
helps search engines reduce duplicate content, as described in more detail in The Canonical
Link Relation. [RFC6596]
dns-prefetch"The dns-prefetch keyword may be used with
link elements. This keyword creates an external
resource link. This keyword is body-ok.
The dns-prefetch keyword indicates that preemptively
performing DNS resolution for the origin of the specified resource is likely to be
beneficial, as it is highly likely that the user will require resources located at that
origin, and the user experience would be improved by preempting the latency costs
associated with DNS resolution.
There is no default type for resources given by the dns-prefetch keyword.
The appropriate times to fetch and process this type of link are:
When the external resource link is created on a link element
that is already browsing-context connected.
When the external resource link's link element becomes
browsing-context connected.
When the href attribute of the link
element of an external resource link that is already browsing-context
connected is changed.
The fetch and process the linked resource steps for this type of linked resource,
given a link element el, are:
Let url be the result of encoding-parsing a URL given
el's href attribute's value, relative to
el's node document.
If url is failure, then return.
Let partitionKey be the result of determining the network partition key given el's node document's relevant settings object.
The user agent should resolve an origin given partitionKey and url's origin.
As the results of this algorithm can be cached, future fetches could be faster.
expect"The expect keyword may be used with link
elements. This keyword creates an internal resource
link.
An internal resource link created by the expect
keyword can be used to block rendering until the element that
it indicates is connected to the document and fully
parsed.
There is no default type for resources given by the expect
keyword.
Whenever any of the following conditions occur for a link element
el:
the expect internal resource link is created
on el that is already browsing-context connected;
an expect internal resource link has been
created on el and el becomes
browsing-context connected;
an expect internal resource link has been
created on el, el is already browsing-context connected, and
el's href attribute is set, changed, or removed;
or
an expect internal resource link has been
created on el, el is already browsing-context connected, and
el's media attribute is set, changed, or
removed,
then process el.
To process internal resource link given a link element el,
run these steps:
Let doc be el's node document.
Let url be the result of encoding-parsing a URL given
el's href attribute's value, relative to
doc.
If this fails, or if url does not equal doc's URL with exclude fragments set to true, then unblock rendering on el and return.
Let indicatedElement be the result of selecting the indicated part given doc and url.
If all of the following are true:
doc's current document readiness is "loading";
el creates an internal resource link;
el is browsing-context connected;
el is potentially render-blocking;
el's media attribute
matches the environment; and
indicatedElement is not an element, or is on a
stack of open elements of an HTML parser whose associated
Document is doc,
then block rendering on el.
Otherwise, unblock rendering on el.
To process internal resource links given a Document doc:
For each expect link element link in
doc's render-blocking element set, process link.
The following attribute change
steps, given element, localName, oldValue,
value, and namespace, are used to ensure expect link elements respond to dynamic id and name changes:
If namespace is not null, then return.
If element is in a stack of open elements of an HTML parser, then return.
If any of the following is true:
then process internal resource links given element's node document.
external"The external keyword may be used with a,
area, and form elements. This keyword does not create a
hyperlink, but annotates any other
hyperlinks created by the element (the implied hyperlink, if no other keywords create one).
The external keyword indicates that the link is leading to a
document that is not part of the site that the current document forms a part of.
help"The help keyword may be used with link,
a, area, and form elements. This keyword creates a
hyperlink.
For a, area, and form elements, the help keyword indicates that the referenced document provides further help
information for the parent of the element defining the hyperlink, and its children.
In the following example, the form control has associated context-sensitive help. The user agent could use this information, for example, displaying the referenced document if the user presses the "Help" or "F1" key.
< p >< label > Topic: < input name = topic > < a href = "help/topic.html" rel = "help" > (Help)</ a ></ label ></ p >
For link elements, the help keyword indicates that
the referenced document provides help for the page as a whole.
For a and area elements, on some browsers, the help keyword causes the link to use a different cursor.
icon"Support in all current engines.
The icon keyword may be used with link elements.
This keyword creates an external resource link.
The specified resource is an icon representing the page or site, and should be used by the user agent when representing the page in the user interface.
Icons could be auditory icons, visual icons, or other kinds of icons. If
multiple icons are provided, the user agent must select the most appropriate icon according to the
type, media, and sizes attributes. If there are multiple equally appropriate icons,
user agents must use the last one declared in tree order at the time that the user
agent collected the list of icons. If the user agent tries to use an icon but that icon is
determined, upon closer examination, to in fact be inappropriate (e.g. because it uses an
unsupported format), then the user agent must try the next-most-appropriate icon as determined by
the attributes.
User agents are not required to update icons when the list of icons changes, but are encouraged to do so.
There is no default type for resources given by the icon keyword.
However, for the purposes of determining the type of the
resource, user agents must expect the resource to be an image.
The sizes keywords represent icon sizes in raw pixels (as
opposed to CSS pixels).
An icon that is 50 CSS pixels wide intended for displays with a device pixel density of two device pixels per CSS pixel (2x, 192dpi) would have a width of 100 raw pixels. This feature does not support indicating that a different resource is to be used for small high-resolution icons vs large low-resolution icons (e.g. 50×50 2x vs 100×100 1x).
To parse and process the attribute's value, the user agent must first split the attribute's value on ASCII whitespace, and must then parse each resulting keyword to determine what it represents.
The any keyword represents that the
resource contains a scalable icon, e.g. as provided by an SVG image.
Other keywords must be further parsed as follows to determine what they represent:
If the keyword doesn't contain exactly one U+0078 LATIN SMALL LETTER X or U+0058 LATIN CAPITAL LETTER X character, then this keyword doesn't represent anything. Return for that keyword.
Let width string be the string before the "x" or
"X".
Let height string be the string after the "x" or
"X".
If either width string or height string start with a U+0030 DIGIT ZERO (0) character or contain any characters other than ASCII digits, then this keyword doesn't represent anything. Return for that keyword.
Apply the rules for parsing non-negative integers to width string to obtain width.
Apply the rules for parsing non-negative integers to height string to obtain height.
The keyword represents that the resource contains a bitmap icon with a width of width device pixels and a height of height device pixels.
The keywords specified on the sizes attribute must not
represent icon sizes that are not actually available in the linked resource.
The linked resource fetch setup steps for this type of linked resource, given a
link element el and request
request, are:
Set request's destination to
"image".
Return true.
The process a link header steps for this type of linked resource are to do nothing.
In the absence of a link with the icon keyword, for
Document objects whose URL's
scheme is an HTTP(S) scheme, user agents may
instead run these steps:
Let request be a new request whose
URL is the URL record obtained by
resolving the URL "/favicon.ico" against the
Document object's URL, client is the Document object's
relevant settings object, destination is "image", credentials mode is "include", and whose use-URL-credentials flag is set.
Fetch request, with processResponse set to the following steps given response response:
Use response's unsafe response as an icon as if it had been
declared using the icon keyword.
The following snippet shows the top part of an application with several icons.
<!DOCTYPE HTML>
< html lang = "en" >
< head >
< title > lsForums — Inbox</ title >
< link rel = icon href = favicon.png sizes = "16x16" type = "image/png" >
< link rel = icon href = windows.ico sizes = "32x32 48x48" type = "image/vnd.microsoft.icon" >
< link rel = icon href = mac.icns sizes = "128x128 512x512 8192x8192 32768x32768" >
< link rel = icon href = iphone.png sizes = "57x57" type = "image/png" >
< link rel = icon href = gnome.svg sizes = "any" type = "image/svg+xml" >
< link rel = stylesheet href = lsforums.css >
< script src = lsforums.js ></ script >
< meta name = application-name content = "lsForums" >
</ head >
< body >
...
For historical reasons, the icon keyword may be preceded by the
keyword "shortcut". If the "shortcut" keyword is
present, the rel attribute's entire value must be an
ASCII case-insensitive match for the string "shortcut icon" (with a single U+0020 SPACE character between the tokens and
no other ASCII whitespace).
license"The license keyword may be used with link,
a, area, and form elements. This keyword creates a
hyperlink.
The license keyword indicates that the referenced document
provides the copyright license terms under which the main content of the current document is
provided.
This specification does not specify how to distinguish between the main content of a document and content that is not deemed to be part of that main content. The distinction should be made clear to the user.
Consider a photo sharing site. A page on that site might describe and show a photograph, and the page might be marked up as follows:
<!DOCTYPE HTML>
< html lang = "en" >
< head >
< title > Exampl Pictures: Kissat</ title >
< link rel = "stylesheet" href = "/style/default" >
</ head >
< body >
< h1 > Kissat</ h1 >
< nav >
< a href = "../" > Return to photo index</ a >
</ nav >
< figure >
< img src = "/pix/39627052_fd8dcd98b5.jpg" >
< figcaption > Kissat</ figcaption >
</ figure >
< p > One of them has six toes!</ p >
< p >< small >< a rel = "license" href = "http://www.opensource.org/licenses/mit-license.php" > MIT Licensed</ a ></ small ></ p >
< footer >
< a href = "/" > Home</ a > | < a href = "../" > Photo index</ a >
< p >< small > © copyright 2009 Exampl Pictures. All Rights Reserved.</ small ></ p >
</ footer >
</ body >
</ html >
In this case the license applies to just the photo (the main
content of the document), not the whole document. In particular not the design of the page
itself, which is covered by the copyright given at the bottom of the document. This could be made
clearer in the styling (e.g. making the license link prominently positioned near the photograph,
while having the page copyright in light small text at the foot of the page).
Synonyms: For historical reasons, user agents must also treat the keyword
"copyright" like the license keyword.
manifest"Support in one engine only.
The manifest keyword may be used with link elements.
This keyword creates an external resource link.
The manifest keyword indicates the manifest file that provides
metadata associated with the current document.
There is no default type for resources given by the manifest
keyword.
When a web application is not installed, the appropriate time to fetch and process the linked resource for this link type is when the user agent deems it necessary. For example, when the user chooses to install the web application.
For an installed web application, the appropriate times to fetch and process the linked resource for this link type are:
When the external resource link is created on a link element
that is already browsing-context connected.
When the external resource link's link element becomes
browsing-context connected.
When the href attribute of the link
element of an external resource link that is already browsing-context
connected is changed.
In any case, only the first link element in tree order whose rel attribute contains the token manifest may be used.
A user agent must not delay the load event for this link type.
The linked resource fetch setup steps for this type of linked resource, given a
link element el and request
request, are:
Let navigable be el's node document's node navigable.
If navigable is null, then return false.
If navigable is not a top-level traversable, then return false.
Set request's initiator to
"manifest".
Set request's destination to
"manifest".
Set request's mode to "cors".
Set request's credentials
mode to the CORS settings attribute credentials mode for el's
crossorigin content attribute.
Return true.
To process this type of linked resource given
a link element el, boolean success, response response, and byte sequence
bodyBytes:
If response's Content-Type metadata is not a JSON MIME type, then set success to false.
If success is true:
Let document URL be el's node document's URL.
Let manifest URL be response's URL.
Let client be el's node document's relevant settings object.
Process the manifest given document URL, manifest URL, bodyBytes, and client. [MANIFEST]
The process a link header steps for this type of linked resource are to do nothing.
modulepreload"The modulepreload keyword may be used with
link elements. This keyword creates an external resource link. This
keyword is body-ok.
The modulepreload keyword is a specialized alternative
to the preload keyword, with a processing model geared toward
preloading module scripts. In particular, it uses the specific
fetch behavior for module scripts (including, e.g., a different interpretation of the crossorigin attribute), and places the result into the
appropriate module map for later evaluation. In
contrast, a similar external resource link using the preload keyword would place the result in the preload cache, without
affecting the document's module map.
Additionally, implementations can take advantage of the fact that module scripts declare their dependencies in order to fetch the specified module's
dependency as well. This is intended as an optimization opportunity, since the user agent knows
that, in all likelihood, those dependencies will also be needed later. It will not generally be
observable without using technology such as service workers, or monitoring on the server side.
Notably, the appropriate load or error events will occur after the specified module is fetched, and
will not wait for any dependencies.
A user agent must not delay the load event for this link type.
A module preload destination is "json", "style", "text", or a script-like destination.
The appropriate times to fetch and process the linked resource for such a link are:
When the external resource link is created on a link element
that is already browsing-context connected.
When the external resource link's link element becomes
browsing-context connected.
When the href attribute of the link
element of an external resource link that is already browsing-context
connected is changed.
Unlike some other link relations, changing the relevant attributes (such as as, crossorigin, and
referrerpolicy) of such a link
does not trigger a new fetch. This is because the document's module map has already been populated by a previous
fetch, and so re-fetching would be pointless.
The fetch and process the linked resource algorithm for modulepreload links, given a link element
el, is as follows:
If el's href attribute's value is the
empty string, then return.
Let destination be the current state of el's as attribute (a destination), or "script" if
it is in no state.
If destination is not a module preload destination, then
queue an element task on the networking task source given el
to fire an event named error at el, and return.
Let url be the result of encoding-parsing a URL given
el's href attribute's value, relative to
el's node document.
If url is failure, then return.
Let settings object be el's node document's relevant settings object.
Let credentials mode be the CORS settings attribute credentials
mode for el's crossorigin
attribute.
Let cryptographic nonce be el.[[CryptographicNonce]].
Let integrity metadata be the value of el's integrity attribute, if it is specified, or the empty string
otherwise.
If el does not have an integrity
attribute, then set integrity metadata to the result of resolving a module
integrity metadata with url and settings object.
Let referrer policy be the current state of el's referrerpolicy attribute.
Let fetch priority be the current state of el's fetchpriority attribute.
Let options be a script fetch options whose cryptographic nonce is cryptographic
nonce, integrity metadata is
integrity metadata, parser
metadata is "not-parser-inserted", credentials mode is credentials
mode, referrer
policy is referrer policy, and fetch priority is
fetch priority.
Fetch a modulepreload module script graph given url, destination, settings object, options, and with the following steps given result:
If result is null, then fire an
event named error at el,
and return.
Fire an event named load at el.
The process a link header steps for this type of linked resource are to do nothing.
The following snippet shows the top part of an application with several modules preloaded:
<!DOCTYPE html>
< html lang = "en" >
< title > IRCFog</ title >
< link rel = "modulepreload" href = "app.mjs" >
< link rel = "modulepreload" href = "helpers.mjs" >
< link rel = "modulepreload" href = "irc.mjs" >
< link rel = "modulepreload" href = "fog-machine.mjs" >
< script type = "module" src = "app.mjs" >
...
Assume that the module graph for the application is as follows:
Here we see the application developer has used modulepreload to declare all of the modules in their module graph,
ensuring that the user agent initiates fetches for them all. Without such preloading, the user
agent might need to go through multiple network roundtrips before discovering helpers.mjs, if technologies such as HTTP/2 Server Push are not in play. In
this way, modulepreload link elements can be
used as a sort of "manifest" of the application's modules.
The following code shows how modulepreload links can
be used in conjunction with import() to ensure network fetching is done ahead of
time, so that when import() is called, the module is already ready (but not
evaluated) in the module map:
< link rel = "modulepreload" href = "awesome-viewer.mjs" >
< button onclick = "import('./awesome-viewer.mjs').then(m => m.view())" >
View awesome thing
</ button >
nofollow"The nofollow keyword may be used with a,
area, and form elements. This keyword does not create a
hyperlink, but annotates any other
hyperlinks created by the element (the implied hyperlink, if no other keywords create one).
The nofollow keyword indicates that the link is not endorsed
by the original author or publisher of the page, or that the link to the referenced document was
included primarily because of a commercial relationship between people affiliated with the two
pages.
noopener"Support in all current engines.
Support in all current engines.
The noopener keyword may be used with a,
area, and form elements. This keyword does not create a
hyperlink, but annotates any other
hyperlinks created by the element (the implied hyperlink, if no other keywords create one).
The keyword indicates that any newly created top-level traversable which results
from following the hyperlink will not contain an auxiliary browsing
context. E.g., the resulting Window's opener
getter will return null.
See also the processing model.
This typically creates a top-level traversable with an auxiliary browsing
context (assuming there is no existing navigable whose target name is "example"):
< a href = help.html target = example > Help!</ a >
This creates a top-level traversable with a non-auxiliary browsing context (assuming the same thing):
< a href = help.html target = example rel = noopener > Help!</ a >
These are equivalent and only navigate the parent navigable:
< a href = index.html target = _parent > Home</ a >
< a href = index.html target = _parent rel = noopener > Home</ a >
noreferrer"Support in all current engines.
Support in all current engines.
The noreferrer keyword may be used with a,
area, and form elements. This keyword does not create a
hyperlink, but annotates any other
hyperlinks created by the element (the implied hyperlink, if no other keywords create one).
It indicates that no referrer information is to be leaked when following the link and also
implies the noopener keyword behavior under the same
conditions.
See also the processing model where referrer is directly manipulated.
<a href="..." rel="noreferrer" target="_blank">
has the same behavior as <a href="..." rel="noreferrer noopener" target="_blank">.
opener"The opener keyword may be used with a,
area, and form elements. This keyword does not create a
hyperlink, but annotates any other
hyperlinks created by the element (the implied hyperlink, if no other keywords create one).
The keyword indicates that any newly created top-level traversable which results from following the hyperlink will contain an auxiliary browsing context.
See also the processing model.
In the following example the opener is used to allow the help
page popup to navigate its opener, e.g., in case what the user is looking for can be found
elsewhere. An alternative might be to use a named target, rather than _blank, but this has the potential to clash with existing names.
< a href = "..." rel = opener target = _blank > Help!</ a >
pingback"The pingback keyword may be used with link
elements. This keyword creates an external resource
link. This keyword is body-ok.
For the semantics of the pingback keyword, see
Pingback 1.0. [PINGBACK]
preconnect"Support in all current engines.
The preconnect keyword may be used with link
elements. This keyword creates an external resource
link. This keyword is body-ok.
The preconnect keyword indicates that preemptively
initiating a connection to the origin of the specified resource is likely to be
beneficial, as it is highly likely that the user will require resources located at that
origin, and the user experience would be improved by preempting the latency costs
associated with establishing the connection.
There is no default type for resources given by the preconnect keyword.
A user agent must not delay the load event for this link type.
The appropriate times to fetch and process this type of link are:
When the external resource link is created on a link element
that is already browsing-context connected.
When the external resource link's link element becomes
browsing-context connected.
When the href attribute of the link
element of an external resource link that is already browsing-context
connected is changed.
When the crossorigin attribute of the
link element of an external resource
link that is already browsing-context connected is set, changed, or
removed.
The fetch and process the linked resource steps for this type of linked resource,
given a link element el, are to create link options from el and
to preconnect given the result.
The process a link header step for this type of linked resource given a link processing options options are to preconnect given options.
To preconnect given a link processing options options:
If options's href is an empty string, return.
Let url be the result of encoding-parsing a URL given options's href, relative to options's base URL.
Passing the base URL instead of a document or environment is tracked by issue #9715.
If url is failure, then return.
If url's scheme is not an HTTP(S) scheme, then return.
Let partitionKey be the result of determining the network partition key given options's environment.
Let useCredentials be true.
If options's crossorigin is Anonymous and options's origin does not have the same origin as url's origin, then set useCredentials to false.
The user agent should obtain a connection given partitionKey, url, and useCredentials.
This connection is obtained but not used directly. It will remain in the connection pool for subsequent use.
The user agent should attempt to initiate a preconnect and perform the full connection handshake (DNS+TCP for HTTP, and DNS+TCP+TLS for HTTPS origins) whenever possible, but is allowed to elect to perform a partial handshake (DNS only for HTTP, and DNS or DNS+TCP for HTTPS origins), or skip it entirely, due to resource constraints or other reasons.
The optimal number of connections per origin is dependent on the negotiated protocol, users current connectivity profile, available device resources, global connection limits, and other context specific variables. As a result, the decision for how many connections should be opened is deferred to the user agent.
prefetch"The prefetch keyword may be used with link
elements. This keyword creates an external resource
link. This keyword is body-ok.
The prefetch keyword indicates that preemptively fetching and caching the specified resource or same-site document is
likely to be beneficial, as it is highly likely that the user will require this resource for
future navigations.
There is no default type for resources given by the prefetch
keyword.
The appropriate times to fetch and process this type of link are:
When the external resource link is created on a link element
that is already browsing-context connected.
When the external resource link's link element becomes
browsing-context connected.
When the href attribute of the link
element of an external resource link that is already browsing-context
connected is changed.
When the crossorigin attribute of the
link element of an external resource
link that is already browsing-context connected is set, changed, or
removed.
The fetch and process the linked resource algorithm for prefetch links, given a link element
el, is as follows:
If el's href attribute's value is the
empty string, then return.
Let options be the result of creating link options from el.
Let request be the result of creating a link request given options.
If request is null, then return.
Set request's initiator to
"prefetch".
Let processPrefetchResponse be the following steps given a response response and null, failure, or a byte sequence bytesOrNull:
If response is a network error, fire an event named error at el.
Otherwise, fire an event named load at el.
The user agent should fetch request, with processResponseConsumeBody set to processPrefetchResponse. User agents may delay the fetching of request to prioritize other requests that are necessary for the current document.
The process a link header steps for this type of linked resource are to do nothing.
preload"Support in one engine only.
The preload keyword may be used with link
elements. This keyword creates an external resource
link. This keyword is body-ok.
The preload keyword indicates that the user agent will
preemptively fetch and cache the specified resource according
to the preload destination given by the as
attribute, and the priority given by the fetchpriority attribute, as it is highly likely that the
user will require this resource for the current navigation.
User-agents might perform additional operations when a resource is loaded, such as preemptively decoding images or creating style sheets. However, these additional operations cannot have observable effects.
There is no default type for resources given by the preload
keyword.
A user agent must not delay the load event for this link type.
The appropriate times to fetch and process the linked resource for such a link are:
When the external resource link is created on a link element
that is already browsing-context connected.
When the external resource link's link element becomes
browsing-context connected.
When the href attribute of the link
element of an external resource link that is already browsing-context
connected is changed.
When the as attribute of the link
element of an external resource link that is already browsing-context
connected is changed.
When the type attribute of the link
element of an external resource link that is already browsing-context
connected, but was previously not obtained due to the type attribute specifying an unsupported type for the request
destination, is set, removed, or
changed.
When the media attribute of the link
element of an external resource link that is already browsing-context
connected, but was previously not obtained due to the media attribute not
matching the environment, is changed or
removed.
A Document has a map of preloaded resources, which is an
ordered map, initially empty.
A preload key is a struct. It has the following items:
same-origin", "cors", or
"no-cors"
A preload key's equality is itemwise equality.
A preload entry is a struct. It has the following items:
To consume a preloaded resource for Window window,
given a URL url, a string destination, a string
mode, a string credentialsMode, a string integrityMetadata, and
onResponseAvailable, which is an algorithm accepting a response:
Let key be a preload key whose URL is url, destination is destination, mode is mode, and credentials mode is credentialsMode.
Let preloads be window's associated Document's map of
preloaded resources.
If key does not exist in preloads, then return false.
Let entry be preloads[key].
Let consumerIntegrityMetadata be the result of parsing integrityMetadata.
Let preloadIntegrityMetadata be the result of parsing entry's integrity metadata.
If none of the following conditions apply:
consumerIntegrityMetadata is no metadata;
consumerIntegrityMetadata is equal to preloadIntegrityMetadata; or
This comparison would ignore unknown integrity options. See issue #116.
then return false.
A mismatch in integrity metadata between the preload and the consumer, even if both match the data, would lead to an additional fetch from the network.
It is important that network errors are added to the preload cache so that if a preload request results in an error, the erroneous response isn't re-requested from the network later. This also has security implications; consider the case where a developer specifies subresource integrity metadata on a preload request, but not the following resource request. If the preload request fails subresource integrity verification and is discarded, the resource request will fetch and consume a potentially-malicious response from the network without verifying its integrity. [SRI]
Remove preloads[key].
If entry's response is null, then set entry's on response available to onResponseAvailable.
Otherwise, call onResponseAvailable with entry's response.
Return true.
For the purposes of this section, a string type matches a preload destination destination if the following algorithm returns true:
If type is an empty string, then return true.
If destination is "fetch", then return true.
Let mimeTypeRecord be the result of parsing type.
If mimeTypeRecord is failure, then return false.
If mimeTypeRecord is not supported by the user agent, then return false.
If any of the following are true:
destination is "script" and
mimeTypeRecord is a JavaScript MIME type;
destination is "image" and
mimeTypeRecord is an image MIME type;
destination is "font" and
mimeTypeRecord is a font MIME type;
destination is "style" and
mimeTypeRecord's essence is
text/css; or
destination is "track" and
mimeTypeRecord's essence is
text/vtt,
then return true.
Return false.
To create a preload key for a request request, return a new preload key whose URL is request's URL, destination is request's destination, mode is request's mode, and credentials mode is request's credentials mode.
A preload destination is "fetch", "font", "image", "script", "style", or "track".
To translate a preload destination given a string destination:
If destination is not a preload destination, then return null.
Return the result of translating destination.
To preload given a link processing options options and an optional processResponse, which is an algorithm accepting a response:
If options's type doesn't match options's destination, then return.
If options's destination is "image" and options's source
set is not null:
Let selected be the result of selecting an image source from a source set given options's source set and options's document.
If selected is null, then return.
Set options's href to selected[0].
Let request be the result of creating a link request given options.
If request is null, then return.
Let unsafeEndTime be 0.
Let entry be a new preload entry whose integrity metadata is options's integrity.
Let key be the result of creating a preload key given request.
If options's document is null, then
set request's initiator type to
"early hint".
Let controller be null.
Let reportTiming given a Document document be to
report timing for controller given document's relevant
global object.
Set controller to the result of fetching request, with processResponseConsumeBody set to the following steps given a response response and null, failure, or a byte sequence bodyBytes:
If bodyBytes is a byte sequence, then set response's body to bodyBytes as a body.
By using processResponseConsumeBody, we have extracted the entire body. This is necessary to ensure the preloader loads the entire body from the network, regardless of whether the preload will be consumed (which is uncertain at this point). This step then resets the request's body to a new body containing the same bytes, so that other specifications can read from it at the time of actual consumption, despite us having already done so once.
Otherwise, set response to a network error.
Set unsafeEndTime to the unsafe shared current time.
If options's document is not null, then call reportTiming given options's document.
If entry's on response available is null, then set entry's response to response; otherwise call entry's on response available given response.
If processResponse is given, then call processResponse with response.
Let commit be the following steps given a Document
document:
If entry's response is not null, then call reportTiming given document.
Set document's map of preloaded resources[key] to entry.
If options's document is null, then set options's on document ready to commit. Otherwise, call commit with options's document.
The fetch and process the linked resource steps for this type of linked resource,
given a link element el, are:
Update the source set for el.
Let options be the result of creating link options from el.
Let destination be the result of translating the keyword representing the state of el's as attribute.
If destination is null, then return.
Set options's destination to destination.
Preload options, with the following steps given a response response:
If response is a network error, fire an event named error at el. Otherwise, fire an event named
load at el.
The actual browsers' behavior is different from the spec here, and the feasibility of changing the behavior has not yet been investigated. See issue #1142.
The process a link header step for this type of link given a link processing options options is to preload options.
privacy-policy"The privacy-policy keyword may be used with
link, a, and area elements. This keyword creates a
hyperlink.
The privacy-policy keyword indicates that the
referenced document contains information about the data collection and usage practices that apply
to the current document, as described in more detail in Additional Link Relation
Types. The referenced document may be a standalone privacy policy, or a specific section of
some more general document. [RFC6903]
search"The search keyword may be used with link,
a, area, and form elements. This keyword creates a
hyperlink.
The search keyword indicates that the referenced document
provides an interface specifically for searching the document and its related resources.
OpenSearch description documents can be used with link elements and
the search link type to enable user agents to autodiscover search
interfaces. [OPENSEARCH]
stylesheet"The stylesheet keyword may be used with link
elements. This keyword creates an external resource
link that contributes to the styling processing model. This keyword is
body-ok.
The specified resource is a CSS style sheet that describes how to present the document.
Support in one engine only.
If the alternate keyword is also specified on the
link element, then the link is an
alternative style sheet; in this case, the title attribute
must be specified on the link element, with a non-empty value.
The default type for resources given by the stylesheet
keyword is text/css.
A link element of this type is implicitly potentially render-blocking
if the element was created by its node document's parser.
When the disabled attribute of a link
element with a stylesheet keyword is set, disable the associated CSS style sheet.
The appropriate times to fetch and process this type of link are:
When the external resource link is created on a link element
that is already browsing-context connected.
When the external resource link's link element becomes
browsing-context connected.
When the href attribute of the link
element of an external resource link that is already browsing-context
connected is changed.
When the disabled attribute of the
link element of an external resource link that is already
browsing-context connected is set, changed, or removed.
When the crossorigin attribute of the
link element of an external resource
link that is already browsing-context connected is set, changed, or
removed.
When the type attribute of the link
element of an external resource link that is already browsing-context
connected is set or changed to a value that does not or no longer matches the Content-Type metadata of the previous obtained external resource, if
any.
When the type attribute of the link
element of an external resource link that is already browsing-context
connected, but was previously not obtained due to the type attribute specifying an unsupported type, is removed or
changed.
When the external resource link that is already browsing-context connected changes from being an alternative style sheet to not being one, or vice versa.
Quirk: If the document has been set to quirks mode, has the
same origin as the URL of the external resource,
and the Content-Type metadata of the external resource is not a
supported style sheet type, the user agent must instead assume it to be text/css.
The linked resource fetch setup steps for this type of linked resource, given a
link element el and request
request, are:
If el's disabled attribute is set,
then return false.
If el contributes a script-blocking style sheet, append el to its node document's script-blocking style sheet set.
If el's media attribute's value
matches the environment and el is
potentially render-blocking, then block rendering on
el.
If el is currently render-blocking, then set request's render-blocking to true.
Return true.
See issue #968 for plans
to use the CSSOM fetch a CSS
style sheet algorithm instead of the default fetch and process the linked
resource algorithm. In the meantime, any critical
subresource request should have its render-blocking set to whether or not the
link element is currently render-blocking.
To process this type of linked resource
given a link element el, boolean success, response response, and byte sequence
bodyBytes:
If the resource's Content-Type metadata is not
text/css, then set success to false.
If el no longer creates an external resource link that contributes to the styling processing model, or if, since the resource in question was fetched, it has become appropriate to fetch it again:
Remove el from el's node document's script-blocking style sheet set.
Return.
If el has an associated CSS style sheet, remove the CSS style sheet.
If success is true:
Create a CSS style sheet with the following properties:
response's URL list[0]
We provide a URL here on the assumption that w3c/csswg-drafts issue #9316 will be fixed.
el
The media attribute of el.
This is a reference to the (possibly absent at this time) attribute, rather than a copy of the attribute's current value. CSSOM defines what happens when the attribute is dynamically set, changed, or removed.
The title attribute of el, if
el is in a document tree, or the empty string otherwise.
This is similarly a reference to the attribute, rather than a copy of the attribute's current value.
Set if the link is an alternative style sheet and el's explicitly enabled is false; unset otherwise.
Set if the resource is CORS-same-origin; unset otherwise.
null
Left at its default value.
Left uninitialized.
This doesn't seem right. Presumably we should be using bodyBytes? Tracked as issue #2997.
The CSS environment encoding is the result of running the following steps: [CSSSYNTAX]
If el has a charset attribute,
get an encoding from that attribute's value. If
that succeeds, return the resulting encoding. [ENCODING]
Otherwise, return the document's character encoding. [DOM]
Fire an event named load at el.
Otherwise, fire an event named error at el.
If el contributes a script-blocking style sheet:
Assert: el's node document's script-blocking style sheet set contains el.
Remove el from its node document's script-blocking style sheet set.
Unblock rendering on el.
The process a link header steps for this type of linked resource are to do nothing.
tag"The tag keyword may be used with a and
area elements. This keyword creates a hyperlink.
The tag keyword indicates that the tag that the
referenced document represents applies to the current document.
Since it indicates that the tag applies to the current document, it would be inappropriate to use this keyword in the markup of a tag cloud, which lists the popular tags across a set of pages.
This document is about some gems, and so it is tagged with "https://en.wikipedia.org/wiki/Gemstone" to unambiguously categorize it as applying
to the "jewel" kind of gems, and not to, say, the towns in the US, the Ruby package format, or
the Swiss locomotive class:
<!DOCTYPE HTML>
< html lang = "en" >
< head >
< title > My Precious</ title >
</ head >
< body >
< header >< h1 > My precious</ h1 > < p > Summer 2012</ p ></ header >
< p > Recently I managed to dispose of a red gem that had been
bothering me. I now have a much nicer blue sapphire.</ p >
< p > The red gem had been found in a bauxite stone while I was digging
out the office level, but nobody was willing to haul it away. The
same red gem stayed there for literally years.</ p >
< footer >
Tags: < a rel = tag href = "https://en.wikipedia.org/wiki/Gemstone" > Gemstone</ a >
</ footer >
</ body >
</ html >
In this document, there are two articles. The "tag"
link, however, applies to the whole page (and would do so wherever it was placed, including if it
was within the article elements).
<!DOCTYPE HTML>
< html lang = "en" >
< head >
< title > Gem 4/4</ title >
</ head >
< body >
< article >
< h1 > 801: Steinbock</ h1 >
< p > The number 801 Gem 4/4 electro-diesel has an ibex and was rebuilt in 2002.</ p >
</ article >
< article >
< h1 > 802: Murmeltier</ h1 >
< figure >
< img src = "https://upload.wikimedia.org/wikipedia/commons/b/b0/Trains_de_la_Bernina_en_hiver_2.jpg"
alt = "The 802 was red with pantographs and tall vents on the side." >
< figcaption > The 802 in the 1980s, above Lago Bianco.</ figcaption >
</ figure >
< p > The number 802 Gem 4/4 electro-diesel has a marmot and was rebuilt in 2003.</ p >
</ article >
< p class = "topic" >< a rel = tag href = "https://en.wikipedia.org/wiki/Rhaetian_Railway_Gem_4/4" > Gem 4/4</ a ></ p >
</ body >
</ html >
terms-of-service"The terms-of-service keyword may be used with
link, a, and area elements. This keyword creates a
hyperlink.
The terms-of-service keyword indicates that the
referenced document contains information about the agreements between the current document's
provider and users who wish to use the current document, as described in more detail in
Additional Link Relation Types. [RFC6903]
Some documents form part of a sequence of documents.
A sequence of documents is one where each document can have a previous sibling and a next sibling. A document with no previous sibling is the start of its sequence, a document with no next sibling is the end of its sequence.
A document may be part of multiple sequences.
next"The next keyword may be used with link,
a, area, and form elements. This keyword creates a
hyperlink.
The next keyword indicates that the document is part of a
sequence, and that the link is leading to the document that is the next logical document in the
sequence.
When the next keyword is used with a link
element, user agents should process such links as if they were using one of the dns-prefetch, preconnect, or
prefetch keywords. Which keyword the user agent wishes to use
is implementation-dependent; for example, a user agent may wish to use the less-costly preconnect processing model when trying to conserve data, battery
power, or processing power, or may wish to pick a keyword depending on heuristic analysis of past
user behavior in similar scenarios.
prev"The prev keyword may be used with link,
a, area, and form elements. This keyword creates a
hyperlink.
The prev keyword indicates that the document is part of a
sequence, and that the link is leading to the document that is the previous logical document in
the sequence.
Synonyms: For historical reasons, user agents must also treat the keyword
"previous" like the prev keyword.
Extensions to the predefined set of link types may be registered on the microformats page for existing rel values. [MFREL]
Anyone is free to edit the microformats page for existing rel values at any time to add a type. Extension types must be specified with the following information:
The actual value being defined. The value should not be confusingly similar to any other defined value (e.g. differing only in case).
If the value contains a U+003A COLON character (:), it must also be an absolute URL.
linkOne of the following:
link elements.link element; it creates a
hyperlink.link element; it creates an external
resource link.a and areaOne of the following:
a and area elements.a and area elements; it creates a
hyperlink.a and area elements; it creates
an external resource link.a and area elements; it annotates other hyperlinks
created by the element.formOne of the following:
form elements.form elements; it creates a
hyperlink.form elements; it creates an external
resource link.form elements; it annotates other hyperlinks created by the
element.A short non-normative description of what the keyword's meaning is.
A link to a more detailed description of the keyword's semantics and requirements. It could be another page on the wiki, or a link to an external page.
A list of other keyword values that have exactly the same processing requirements. Authors should not use the values defined to be synonyms, they are only intended to allow user agents to support legacy content. Anyone may remove synonyms that are not used in practice; only names that need to be processed as synonyms for compatibility with legacy content are to be registered in this way.
One of the following:
If a keyword is found to be redundant with existing values, it should be removed and listed as a synonym for the existing value.
If a keyword is registered in the "proposed" state for a period of a month or more without being used or specified, then it may be removed from the registry.
If a keyword is added with the "proposed" status and found to be redundant with existing values, it should be removed and listed as a synonym for the existing value. If a keyword is added with the "proposed" status and found to be harmful, then it should be changed to "discontinued" status.
Anyone can change the status at any time, but should only do so in accordance with the definitions above.
Conformance checkers must use the information given on the microformats page for existing rel values to establish if a value is allowed or not: values defined in this specification or marked as "proposed" or "ratified" must be accepted when used on the elements for which they apply as described in the "Effect on..." field, whereas values marked as "discontinued" or not listed in either this specification or on the aforementioned page must be rejected as invalid. Conformance checkers may cache this information (e.g. for performance reasons or to avoid the use of unreliable network connectivity).
When an author uses a new type not defined by either this specification or the wiki page, conformance checkers should offer to add the value to the wiki, with the details described above, with the "proposed" status.
Types defined as extensions in the microformats
page for existing rel values with the status "proposed" or "ratified" may be used with the
rel attribute on link, a, and area
elements in accordance to the "Effect on..." field. [MFREL]