Open In App

How to use the target attribute and the rel attribute in the <a> Tag ?

The target and rel attributes in the <a> (anchor) tag is used to control the behaviour of hyperlinks, specifying how the linked content should be opened and establishing relationships between the current and linked documents. Here’s how to use these attributes:

target Attribute:

The target attribute determines where the linked content will be displayed. Common values for the target attribute are:



Syntax:

<a href="https://www.example.com" target="_blank">Visit Example Website</a>

rel Attribute:

The rel attribute establishes relationships between the current document and the linked document. Common values for the rel attribute include:

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

Combined Usage:

You can use both attributes together for more control over link behavior.



<a href="https://www.geeksforgeeks.org" 
target="_blank" rel="noopener noreferrer">
Visit Example Website
</a>
Article Tags :