The Wayback Machine - https://web.archive.org/web/20250112111354/https://www.geeksforgeeks.org/html-a-target-attribute/
Open In App

HTML <a> target Attribute

Last Updated : 29 Jul, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The HTML <a> target Attribute is used to specify where to open the linked document. This attribute enhances the functionality and user experience by allowing developers to control the behavior of links.

Syntax

<a target="_blank | _self | _parent | _top | framename"\> 

Attribute Values

  • _blank: It opens the link in a new window.
  • _self: It is the default value. It opens the linked document in the same frame.
  • _parent: It opens the linked document in the parent frameset.
  • _top: It opens the linked document in the full body of the window.
  • framename: It opens the linked document in the named frame.

Example: In this example, the GeeksforGeeks link will open in the new tab.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>HTML a target Attribute</title>
</head>

<body>
    <h2>GeeksforGeeks</h2>

    <h3>HTML &lt;a&gt; target Attribute</h3>

    <p>Welcome to
        <a href="https://www.geeksforgeeks.org/" 
            target="_blank">
            GeeksforGeeks
        </a>
    </p>
</body>

</html>

Output

Example: This example illustrates the use of the Target attribute in the <a> element. 

HTML
<!DOCTYPE html>
<html>

<head>
    <title>HTML a target Attribute</title>
</head>

<body>
    <h1>GeeksforGeeks</h1>
    <h2>HTML a Target Attribute</h2>

    <p>Welcome to
        <a href="https://www.geeksforgeeks.org/" 
            target="_self">
            GeeksforGeeks
        </a>
    </p>
</body>

</html>

Output

Supported Browsers

  • Chrome 1
  • Edge 12
  • Firefox 1
  • Opera 15
  • Safari 1

Dive deep into the world of JavaScript with our JavaScript Full Course Online, offering everything from the basics to advanced techniques. Learn how to build interactive websites, optimize your code, and earn a certification to showcase your skills.

Take the Three 90 Challenge! Complete 90% of the course in 90 days, and earn a 90% refund. Push your limits and stay motivated as you work towards mastering JavaScript. Join now and get started on your JavaScript learning journey!


Similar Reads

three90RightbarBannerImg