rel

In HTML, the rel attribute specifies the relationship between the current document and a linked resource, such as a stylesheet, noopener, or noreferrer.

rel Attribute

The rel attribute describes the connection between a linked resource and the current page. It is commonly used with <link>, <a>, <area>, and <form> elements.

Syntax

index.html
<tagname rel="nofollow | noopener | noreferrer | stylesheet | icon | canonical | dns-prefetch | external | author | help | license | prev | next | bookmark | search | alternate | tag" />

Example

  • Link with rel attribute
The a rel attribute

https://institute.qarpeo.com

index.html
<h1>The a rel attribute</h1>
<p><a rel="nofollow" href="https://institute.qarpeo.com/">https://institute.qarpeo.com</a></p>

Area

  • An image map, with a clickable area:
::atter-coords ::
index.html
<img src ="img.jpg" width="145" height="126" alt="Laptop"
usemap="#planetmap">
<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun">
  <area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury">
  <area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus">
</map>

Applies to

The rel attribute can be used on the following elements:

ElementsAttribute
<a>rel
<area>rel
<link>rel
<form>rel

Key Points

  • Purpose: Defines the relationship between the current document and a linked resource.
  • Usage: The applicable values depend on the element.
  • Values: Should be unique and separated by spaces. Common values include:
    • alternate, canonical, stylesheet (for <link>)
    • author, bookmark, next, prev (for <a>)
    • help, license, search (for <form>)

Important Values

  • stylesheet: Links to an external CSS file.
  • canonical: Marks the preferred URL for the page.
  • nofollow: Tells search engines not to follow the link.
  • noopener, noreferrer: Enhances security when opening links in new tabs or windows by mitigating risks.

Conclusion

The rel attribute in HTML defines the relationship between the current document and a linked resource, often used in elements like <a>, <link>, <area>, and <form>. It supports various values such as stylesheet, nofollow, noopener, and canonical, each serving different purposes like linking to a CSS file, instructing search engines, or enhancing security. Correct usage of the rel attribute improves navigation, SEO, and security.