HTML Link rel Types, Resource Hints, and Hyperlink Semantics
What HTML link rel keywords do—preload vs prefetch vs preconnect, modulepreload, noopener, noreferrer, canonical, and the ping attribute.
This page summarizes the WHATWG HTML Living Standard on links: the rel attribute on link, a, area, and form elements, with emphasis on resource hints (preload, prefetch, preconnect, dns-prefetch, modulepreload), hyperlink annotations (noopener, noreferrer), and hyperlink auditing (ping). The edition for web developers restates the same semantics in plainer form.
Three kinds of links: external resources, hyperlinks, and internal links
Section titled “Three kinds of links: external resources, hyperlinks, and internal links”HTML treats links as a conceptual construct created by a, area, form, and link elements. The specification distinguishes three kinds:
Links are a conceptual construct, created by a, area, form, and link elements, that represent a connection between two resources, one of which is the current Document. There are three kinds of links in HTML:
Links to external resources … Hyperlinks … Internal resource links …
— WHATWG, 4.6 Links — Introduction
External resource links are fetched and processed automatically (for example rel="stylesheet" or rel="preload"). Hyperlinks are exposed so the user can navigate (typical a href). Internal resource links attach meaning to parts of the current document (for example rel="expect"). For a and area, an href without hyperlink-defining rel keywords still creates an implied hyperlink with no special link type.
Keywords in rel are ASCII case-insensitive and must not be duplicated on one attribute. Several keywords are body-ok, so link may appear in the document body: dns-prefetch, modulepreload, pingback, preconnect, prefetch, preload, and stylesheet. See the summary table in Link types.
Resource hints: when to use preload, prefetch, preconnect, and dns-prefetch
Section titled “Resource hints: when to use preload, prefetch, preconnect, and dns-prefetch”Developers often add link elements to warm up the network before a subresource or navigation is needed. The specification assigns different fetch behavior to each keyword.
rel keyword |
Primary intent | Typical timing | Needs as? |
Link header / 103 early hints |
|---|---|---|---|---|
dns-prefetch |
DNS resolution for an origin | On connect / href change |
No | Via header processing for some types |
preconnect |
TCP/TLS (or partial handshake) to an origin | On connect / href or crossorigin change |
No | Yes (preconnect) |
prefetch |
Fetch and cache for future navigations | Low priority vs current page | No | No (steps do nothing) |
preload |
Fetch for current navigation | High priority; uses preload map | Yes (as) |
Yes (preload) |
modulepreload |
Module script graph into module map | Like preload for modules | Optional as |
No |
preload: current navigation and the as attribute
Section titled “preload: current navigation and the as attribute”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.
— WHATWG, Link type “preload”
A user agent must not delay the load event for preload. Preloaded responses are keyed in the document’s map of preloaded resources; a later script, img, or other consumer can consume a preloaded entry only when URL, destination, mode, credentials mode, and integrity metadata match—otherwise the browser fetches again. Mismatched integrity between preload and consumer is both a performance and a security issue (see preload and Subresource Integrity notes there).
prefetch vs preload
Section titled “prefetch vs preload”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.
— WHATWG, Link type “prefetch”
Prefetch uses initiator "prefetch" and may be deprioritized; it is for likely next pages, not critical assets for the page you are on. Lighthouse preload guidance notes that preloading is widely supported in Chromium-based browsers; treat other engines as a compatibility check.
preconnect and dns-prefetch
Section titled “preconnect and dns-prefetch”The preconnect keyword indicates that preemptively initiating a connection to the origin of the specified resource is likely to be beneficial …
— WHATWG, Link type “preconnect”
Preconnect should obtain a connection in the pool (full handshake when possible). For cross-origin HTTPS with crossorigin="anonymous" when origins differ, credentials are not used on the connection. Lighthouse preconnect states that rel=preconnect is supported on most browsers.
dns-prefetch only resolves the origin’s DNS—cheaper than preconnect when you are unsure you will need the origin.
modulepreload: module map, not generic preload cache
Section titled “modulepreload: module map, not generic preload cache”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 … and places the result into the appropriate module map for later evaluation.
— WHATWG, Link type “modulepreload”
Implementations may also fetch static dependencies declared in the module graph. Changing as, crossorigin, or referrerpolicy after the first fetch does not trigger a new fetch because the module map is already populated—a difference from preload.
Example pattern from the spec:
<link rel="modulepreload" href="app.mjs"><link rel="modulepreload" href="helpers.mjs"><script type="module" src="app.mjs"></script>crossorigin on link and other media elements
Section titled “crossorigin on link and other media elements”Resource hints and stylesheets use CORS settings attributes (crossorigin):
| Keyword | Credentials on CORS fetch |
|---|---|
| (missing) | No CORS state |
anonymous |
same-origin |
use-credentials |
include |
— after WHATWG, CORS settings attributes
For modern features where the request mode is always "cors", the attribute mainly controls credentials mode. Preconnect reads crossorigin when deciding useCredentials (preconnect processing).
link in markup, Link response headers, and 103 early hints
Section titled “link in markup, Link response headers, and 103 early hints”link elements run fetch and process the linked resource algorithms defined per link type (semantics — fetching from link). Many types also define process a link header steps for HTTP Link headers.
Early hints (status 103) let the server start speculative loads before the final response:
Early hints allow user-agents to perform some operations, such as to speculatively load resources that are likely to be used by the document, before the navigation request is fully handled by the server and a response code is served.
— WHATWG, Early hints
Only the first early hint response in the final redirect chain is honored; a cross-origin redirect discards early hints. Early-hint Link headers are processed before Link on the final response, then before link elements in the document—equivalent to prepending those links to head (early hint processing). For rel=preload, an early-hint fetch may set initiator type "early-hint" and commit into the preload map when the Document exists.
The type attribute on link is not authoritative after fetch; the user agent uses actual Content-Type (with special rules for stylesheets) (processing the type attribute).
Hyperlink rel: canonical, noopener, noreferrer, and nofollow
Section titled “Hyperlink rel: canonical, noopener, noreferrer, and nofollow”Some keywords create hyperlinks; others only annotate hyperlinks created by the same element.
Canonical (only on link in the spec’s definition):
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 …
— WHATWG, Link type “canonical”
noopener prevents an auxiliary browsing context so window.opener is null on the new top-level traversable:
The keyword indicates that any newly created top-level traversable which results from following the hyperlink will not contain an auxiliary browsing context.
— WHATWG, Link type “noopener”
noreferrer suppresses referrer information and, under the same conditions, implies noopener:
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.
— WHATWG, Link type “noreferrer”
nofollow is an annotation that the author does not endorse the target (nofollow). Use rel="noreferrer" with target="_blank" when you want both behaviors without listing both tokens.
Hyperlink auditing: the ping attribute and text/ping
Section titled “Hyperlink auditing: the ping attribute and text/ping”When a user follows a hyperlink on a or area that has a ping attribute, the user agent may send background POST requests to each listed ping URL with body PING and Content-Type: text/ping:
If used exclusively in the fashion described in the context of hyperlink auditing, this type introduces no new security concerns.
— IANA / WHATWG, text/ping
The ping attribute is redundant with pre-existing technologies like HTTP redirects and JavaScript … However, the ping attribute provides these advantages to the user over those alternatives: It allows the user to see the final target URL unobscured. It allows the UA to inform the user about the out-of-band notifications. It allows the UA to optimize the use of available network bandwidth …
— WHATWG, Hyperlink auditing
Cross-origin or non-HTTPS documents may send Ping-From and Ping-To headers (Ping-From and Ping-To). User agents may ignore ping URLs based on user preferences (for example alongside Referer controls).
Common mistakes
Section titled “Common mistakes”- Using
preloadwithoutas, or with atypethat does not match the destination—fetch may be skipped (preload). preloadvsprefetch: preload is for the current page; prefetch is for likely future navigations.- Integrity mismatch: different
integrityon preload and on the consuming tag forces a second network fetch. rel=preloadfor modules instead ofmodulepreload, which populates the module map with correct module script behavior.- Assuming
noopener/noreferrerreplace server-side isolation headers—they only affect window relationships and referrer on navigation. canonicalona—the canonical keyword is defined forlink, not as a substitute for duplicate URL management in anchors (canonical).
How to check this on your site
Section titled “How to check this on your site”- Open DevTools Network on your page, reload, and filter by initiator or name: confirm
preload/prefetch/preconnectrequests appear when expected and that preloaded scripts or images are not duplicated unless keys differ. - For hint coverage, run Lighthouse “Preload key requests” and “Preconnect to required origins” and address flagged URLs with the appropriate
relkeyword. - Validate
linkmarkup against the link types table (allowed elements, body-ok, and whetherLinkheader processing exists for your relation). - For
target="_blank"outbound links, inspect a test navigation: withrel="noopener noreferrer", the new browsing context should not exposeopenerand should not send a referrer, per noopener and noreferrer. - You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact sentence you are asking about.