Home / Learn HTML / Link rel Values and Resource Hints
Link rel Values and Resource Hints
The rel attribute tells the browser how a linked file relates to your page. Some values make pages load faster.
Theory in plain words
What it is
Resource hints such as preload, preconnect and prefetch tell the browser what it will need soon.
Why we use it
They make pages load faster by starting work early.
How it works
link rel values give hints. The browser may start connections or downloads before it needs them.
Where it is used
- Preloading fonts
- Connecting to CDNs
- Prefetching next pages
Common rel values
| rel | Use it for |
|---|---|
stylesheet | A CSS file |
icon, apple-touch-icon | Favicon and phone home-screen icon |
manifest | The web app manifest |
canonical | The preferred URL of a page (SEO) |
alternate | Other versions: language (hreflang), RSS feed |
prev, next | Pages in a series |
author, license | Who wrote it and under which licence |
search | An OpenSearch description |
nofollow, sponsored, ugc | On links: hints for search engines |
noopener, noreferrer | On links that open a new tab: safety and privacy |
Resource hints: load faster
| Hint | What it does | When |
|---|---|---|
preload | Download now with high priority | A font, hero image or key script used on this page |
prefetch | Download later with low priority | The next page the visitor will probably open |
preconnect | Open the connection (DNS, TCP, TLS) early | A CDN or font server you will use soon |
dns-prefetch | Only look up the DNS name | A cheaper hint for many third-party hosts |
modulepreload | Download and parse a JavaScript module | Modules used on this page |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="preload" href="/fonts/inter.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" as="image" href="/img/hero.webp" fetchpriority="high">
<link rel="prefetch" href="/next-page.html">
<link rel="modulepreload" href="/js/app.js">Import maps and speculation rules
<script type="importmap">
{ "imports": { "lodash": "https://cdn.jsdelivr.net/npm/lodash-es@4/lodash.js" } }
</script>
<script type="module">
import { chunk } from "lodash";
console.log(chunk([1, 2, 3, 4], 2));
</script><script type="speculationrules">
{ "prerender": [ { "urls": ["/pricing.html"] } ] }
</script>fetchpriority="high" tells the browser this image matters most.
Quick quiz
1. Which hint downloads a file needed on THIS page right now?
preload is high priority for the current page.
2. Why does a font preload need crossorigin?
Without it the file is fetched twice.
3. Which rel gives the preferred URL for SEO?
rel=canonical tells search engines the main version.
Common questions
Which hint downloads a file needed on THIS page right now?
preload. preload is high priority for the current page.
Why does a font preload need crossorigin?
Fonts are always fetched in CORS mode. Without it the file is fetched twice.
Which rel gives the preferred URL for SEO?
canonical. rel=canonical tells search engines the main version.