HTML & CSS Interview Question #16
What is the purpose of the target and rel attributes on links?
HTML Fundamentals, Structure, Semantics, Links, Images, Tables & Forms Junior Beginner
Quick Interview Answer
target controls where a linked resource is opened. For example, target="_blank" requests a new browsing context, commonly a new tab.
Detailed Explanation
target controls where a linked resource is opened. For example, target="_blank" requests a new browsing context, commonly a new tab.
rel describes the relationship between the current document and the linked resource. For links opened with _blank, modern browsers provide protections against opener access in many cases, but rel="noopener" is still commonly used for explicitness and compatibility. noreferrer additionally suppresses referrer information and implies opener protection.
Code Example
<a href="https://example.com"
target="_blank"
rel="noopener noreferrer">
External Website
</a>