The HTML rel attribute
The HTML rel attribute defines the relationship between the current document and the linked resource. It is used on the <a>, <area>, <link> and <form> elements.
Overview
The rel (relationship) attribute describes how a linked resource relates to the current document. On a <link> it is essential — rel="stylesheet" loads CSS, rel="icon" sets the favicon, and rel="canonical" declares the page's preferred URL for SEO. On an <a> or <area> it adds link relationships and hints.
On links, the security and privacy values matter: rel="noopener" stops a newly opened page from reaching back through window.opener, rel="noreferrer" withholds the referrer, and rel="nofollow", "ugc" and "sponsored" tell search engines how to treat the link (user-generated content, paid placements).
On <link>, performance hints (preload, preconnect, dns-prefetch) and rel="canonical" are key for speed and SEO. The attribute takes a space-separated list, so you can combine values such as rel="noopener noreferrer".
Syntax
<link rel="stylesheet" href="style.css">
Values
| Value |
|---|
A space-separated list of link types, e.g. nofollow, noopener, noreferrer, stylesheet, preload, canonical, icon, sponsored, ugc. |
Best practices
- On a <link>, use the right
rel—stylesheet,icon,canonicalor a performance hint. - On external links opened with target
="_blank", addrel="noopener noreferrer". - Use
rel="nofollow","sponsored"or"ugc"to tell search engines how to treat a link. - Combine multiple values space-separated, e.g.
rel="noopener noreferrer".
Frequently asked questions
What does the rel attribute do?
What is rel="noopener"?
window.opener, closing a security and performance hole.What is rel="nofollow"?
Can rel have more than one value?
rel="noopener noreferrer".