Computer >> Computer tutorials >  >> Programming >> HTML

How to change the target of a link in HTML?


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:

AttributeDescription
_blankOpens the linked page in a new tab.
selfOpens the linked page in the current tab.
ParentOpens the linked page in a parent frame.
TopOpens the linked page in the topmost frame.

How to change the target of a link in HTML?

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>