Assuming I have this HTML code:
<a href="mailto:[email protected]" target="_blank"></a>
As far as I know, for security and privacy reason, best practices tells I have to add rel="noopener noreferrer"
on every link that goes outside. Do I have to consider a mailto
link as an external link?
The noopener is needed to enhance the security of your website and prevent other websites from gaining access to your page (through the browser session). The noreferrer is used to protect referral information from being passed to the target website and this also hides referral traffic in Google analytics.
Adding the nofollow attribute to a link that includes rel=”noopener noreferrer” allows you to link to other websites without appearing to approve their content or perspective.
The noopener keyword for the rel attribute of the <a> , <area> , and <form> elements instructs the browser to navigate to the target resource without granting the new browsing context access to the document that opened it — by not setting the Window. opener property on the opened window (it returns null ).
A mailto link is different than a contact form link. Essentially, an HTML mailto link is a link that triggers the user's default mail client to open so they can reply to a message. If you're a fan of email HTML forms and know your way around the coding aspect of things, a mailto link can be preferable, in some cases.
You can better understand it here: https://mathiasbynens.github.io/rel-noopener/
Short answer: no need, since the link doesn't open a new window
which could (ab)use the window.opener
issue explained in the link above.
UPDATE: As op pointed out - my assumption that a mail client will handle the mailto:
links was wrong. One could have used navigator.registerProtocolHandler
to make a web app handle these links (or any other links for that matter). Thus, I would say you should add rel="noopener noreferrer"
as originally proposed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With