Nofollow vs Noopener vs Noreferrer: Differences and Examples in Link Tag Syntax

By: Rajat Kumar | Last Updated: April 16, 2023

Introduction:

The rel attribute is used to specify the relationship between the current document and the linked document in HTML. The nofollow, noopener, and noreferrer values of the rel attribute serve different purposes. The following are the differences between the nofollow, noopener, and noreferrer values of the rel attribute, along with examples and syntax:

 

nofollow:

When a link has the rel="nofollow" attribute, it tells search engines that they should not follow the link and that the link should not pass any "link juice" or page ranking to the linked page. This is often used for user-generated content, comments, or paid links to discourage spam or manipulation of search engine rankings.

Syntax:

<a href="URL" rel="nofollow">Link text</a>

Example:

<a href="https://example.com" rel="nofollow">Link</a>

In this example, the link to https://example.com has the rel="nofollow" attribute. This tells search engines not to follow the link and not to pass any page ranking to the linked page. This is useful for preventing spam links or paid links from manipulating search engine rankings.

 

noopener:

When a link has the rel="noopener" attribute, it tells the browser to disable the ability of the linked page to control the page that opened it. This is a security measure that prevents the linked page from using the window.opener property to access, which could be used to execute malicious scripts or phishing attacks, and potentially modify the page that opened it. This is important to prevent cross-site scripting (XSS) attacks. This is important for links that open in a new tab or window using the target="_blank" attribute.

Syntax:

<a href="URL" target="_blank" rel="noopener">Link text</a>

Example:

<a href="https://example.com" target="_blank" rel="noopener">Link</a>

In this example, the link to https://example.com has the rel="noopener" attribute. This tells the browser to disable the window.opener property for the linked page, which prevents it from accessing or modifying the page that opened it. This is important for preventing XSS attacks.

Note that the noopener attribute should only be used with the target="_blank" attribute, as it is only necessary when opening a link in a new tab or window. If the link is opened in the same tab or window, the noopener attribute is not necessary.

 

 

 

noreferrer:

When a link has the rel="noreferrer" attribute, it tells the browser to not send the Referer header when the linked page is opened. The Referer header is a part of the HTTP request that tells the server where the user came from. This is often used for privacy reasons, as it prevents the linked page from knowing where the user came from.

Syntax:

<a href="URL" rel="noreferrer">Link text</a>

Example:

<a href="https://example.com" rel="noreferrer">Link</a>

In this example, the link to https://example.com has the rel="noreferrer" attribute. This tells the browser not to send the Referer header when the linked page is opened, which prevents the linked page from knowing where the user came from. This can be useful for protecting user privacy.

Note that the noreferrer attribute is not supported in all browsers, so it is not a foolproof way to protect user privacy. Additionally, some analytics tools may rely on the Referer header to track user behavior, so using the noreferrer attribute may affect analytics data.

Overall, the nofollow, noopener, and noreferrer values of the rel attribute can be useful for controlling the behavior of links in HTML. They are important for preventing

 

Conclusion:

You can use rel="noopener noreferrer" with every link on your website, but it is not always necessary or appropriate. Also the rel="nofollow" must be use with caution and with the links that you do not want to be crawled by search engines, as this will affect your SEO and certainly the important links of sites.

It is generally recommended to use rel="noopener noreferrer" for all external links that open in a new tab or window using the target="_blank" attribute. This is because malicious websites can exploit the window.opener property of the current page to execute scripts or phishing attacks.

However, for internal links within your own website, it is not necessary to use rel="noopener noreferrer". This is because internal links do not open in a new tab or window, so there is no risk of a malicious website accessing the window.opener property.

But it is generally recommended to include rel="noopener" or rel="noreferrer" (or both) when using target="_blank" to open a link in a new tab. This is to prevent a potential security vulnerability known as a "tabnabbing" attack, where the new tab could potentially access the parent tab's content and modify it without the user's knowledge.

Here are some considerations to keep in mind:

  1. Security: If your website allows user-generated content or if you link to external websites that you do not fully trust, using rel="noopener noreferrer" can help improve security and protect your visitors from potential malicious attacks.
  2. Analytics: If you rely on tracking where your website traffic is coming from, using rel="noreferrer" can make it more difficult to track referral traffic accurately.
  3. Performance: Adding rel="noopener noreferrer" to every link on your website can add unnecessary HTML markup and potentially slow down page load times.

In general, it's a good idea to use rel="noopener noreferrer" with links that open in a new tab or window and when linking to external websites that you do not fully trust. For other links, it may not be necessary.

So, it is not required to use rel="noopener noreferrer" for every link in your website, but it is recommended to use it for external links that open in a new tab or window.

 

Views