To change the target of a link in HTML, use the target attribute of the <a>…</a> tag. The target attribute can be used to open any link in a new tab, or the same tab, etc.
Here are the values of the target attribute:
Attribute | Description |
---|---|
_blank | Opens the linked page in a new tab. |
self | Opens the linked page in the current tab. |
Parent | Opens the linked page in a parent frame. |
Top | Opens the linked page in the topmost frame. |
Example
You can try to run the following code to change the target of a link in HTML. We will set it to open in a new tab
<!DOCTYPE html> <html> <head> <title>HTML link target</title> </head> <body> <h2>References</h2> <p> Refer the following <a href="https://www.qries.com/questions.php" target="_blank">website</a>. The above link will open in a new tab. </p> </body> </html>