HTML rel Attribute

The HTML rel attribute defines the relationship between the current document and a linked resource. Its value consists of one or more space-separated keywords that describe the purpose or relationship of the link.

Elements That Use the rel Attribute

The rel attribute is used with the <a>, <area>, <form>, and <link> elements. The link relation keywords that are allowed depend on the element.

Element Description
<a> Defines the relationship between the current document and the destination of a hyperlink.
<area> Defines the relationship between the current document and the destination of an image map hyperlink.
<form> Defines a relationship associated with the hyperlink created by submitting the form.
<link> Defines the relationship between the current document and a linked resource.

rel Values

The rel attribute accepts link relation keywords. Some keywords apply only to certain elements, so not every value can be used with every element that supports rel.

Value Description
alternate Identifies an alternate representation of the current document.
author Links to information about the author of the document or article.
canonical Identifies the preferred URL for the current document.
help Identifies a resource that provides context-sensitive help.
icon Identifies an icon that represents the current document.
license Identifies a resource containing licensing information.
next Identifies the next document in a sequence.
nofollow Indicates that the current document's author or publisher does not endorse the referenced document.
noopener Prevents a newly opened top-level browsing context from having an opener relationship with the current document.
noreferrer Prevents referrer information from being sent when following the hyperlink and also has the effect of noopener.
prev Identifies the previous document in a sequence.
search Identifies a resource that provides an interface for searching the current document or related resources.
stylesheet Identifies an external stylesheet associated with the document.

These are common rel values rather than a complete list. HTML defines additional link relation keywords for specialized purposes.

Multiple rel Values

The rel attribute can contain more than one relationship. Multiple keywords are separated by spaces and form an unordered set.

<a href="https://www.example.com/" rel="nofollow noreferrer">
  Visit Example
</a>

Each keyword describes a relationship or processing behavior that applies to the link. A keyword should not appear more than once in the same rel attribute.

On <a> and <area> elements, the rel attribute describes the relationship between the current document and the hyperlink destination.

<a href="/about.html" rel="author">About the Author</a>

Some link relation values also affect how the browser processes a hyperlink. For example, noreferrer prevents referrer information from being included when the link is followed.

<a href="https://www.example.com/" rel="noreferrer">
  Visit Example
</a>

The <link> element uses rel to describe how an external or linked resource relates to the current document. The value can also determine how the browser processes that resource.

Stylesheet

<link rel="stylesheet" href="styles.css">

The stylesheet value identifies the linked resource as a stylesheet that applies to the document.

Document Icon

<link rel="icon" href="favicon.ico">

The icon value identifies a resource that represents the document in browser interfaces.

Canonical URL

<link rel="canonical" href="https://www.example.com/page.html">

The canonical value identifies the preferred URL for the current document.

rel with Forms

The rel attribute can also be used on the <form> element. Only link relation keywords that are defined as valid for forms can be used.

<form action="/search.html" method="get" rel="search">
  <label for="search">Search:</label>
  <input type="search" id="search" name="q">
  <button type="submit">Search</button>
</form>

In this example, rel="search" indicates that the form's destination provides a search interface.

Common Mistakes

Do not assume that every rel value is valid on every element. Individual link relation keywords define which elements can use them.

Do not separate multiple rel values with commas. The attribute uses space-separated keywords, such as rel="nofollow noreferrer".

Do not repeat the same keyword within one rel attribute. The value is an unordered set of unique space-separated tokens.

Do not use rel="shortcut icon" for a favicon. The shortcut link relation is non-conforming; use rel="icon".

Browser Support

Baseline: Widely available indicates a feature has been supported by core browsers for at least 30 months. At this stage, the feature is considered stable and safe for most websites to use without needing to worry about compatibility issues or fallbacks, as it is supported by the vast majority of users' devices and browser versions.

The rel attribute is widely supported on applicable HTML elements in current core browsers. Support and behavior for individual link relation keywords can vary because each relationship defines its own processing rules.

Checking Browser Support

For current browser compatibility information, visit Can I Use? . Search for the HTML element or attribute you want to check. You can also narrow your search by entering an element name and attribute name separated by a colon. Search results can include related HTML features, element attributes, input types, APIs, and other technologies, so select the result that most closely matches the feature you are checking.

Try the rel Attribute

The example uses rel="noreferrer" on an external hyperlink. The relationship prevents referrer information from being sent when the link is followed.

Play in Editor

Summary

The HTML rel attribute defines the relationship between the current document and a linked resource. It is used with the <a>, <area>, <form>, and <link> elements, and its value consists of one or more unique space-separated link relation keywords. The available relationships and their behavior depend on the element and the individual rel value.