Open In App

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

Last Updated : 24 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The target Attribute in the <a> Tag is used to specify where the linked document should be displayed when the user clicks on the hyperlink. It controls the behavior of the link, determining whether the linked content should open in the same browser window, a new browser window, or a new tab. The target attribute accepts different values that define the target location.

Syntax

<a href="https://www.geeksforgeeks.com" target="_blank">
GeeksforGeeks
</a>

Attribute Values

Here are common values for the target attribute:

  • _blank: Opens the linked document in a new browser window or tab.
  • _self: Default behavior. Opens the linked document in the same window or tab.
  • _parent: Opens the linked document in the parent frame.
  • _top: Opens the linked document in the full body of the window.

Example: Implementation of the target attribute in HTML.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1.0">
    <title>Numbering</title>
</head>
  
<body>
    <a href="https://www.geeksforgeeks.org" 
       target="_blank">GeeksforGeeks
      </a>
</body>
  
</html>


Output:

klo


Similar Reads

How to use the target attribute and the rel attribute in the &lt;a&gt; Tag ?
The target and rel attributes in the &lt;a&gt; (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
2 min read
What is the use of target Attribute in &lt;a&gt; Tags ?
The "target" attribute in &lt;a&gt; tags are used to specify where the linked document should be displayed when the user clicks on the link. It determines the browser context in which the linked content will open, such as in a new window, a new tab, or the same frame or window. Syntax&lt;a href="URL" target="_blank"&gt;Link Text&lt;/a&gt;Key PointD
2 min read
What is use of poster attribute in the HTML video Tag?
The "poster" attribute in &lt;video&gt; Tags are used to specify an image that represents the video content before the video is played or while the video is loading. This attribute allows developers to display a custom poster image, such as a thumbnail or a promotional image, to provide a visual preview or context for the video content. Syntax&lt;v
2 min read
How to use the shape attribute in the HTML img Tag ?
The "shape" attribute in &lt;img&gt; Tags are used in conjunction with client-side image maps to define the shape of clickable areas within an image. This attribute specifies the shape of the clickable region, allowing developers to create non-rectangular clickable areas such as circles, rectangles, or polygons. Syntax&lt;img src="image.jpg" usemap
2 min read
HTML | &lt;area&gt; target Attribute
The HTML &lt;area&gt; target Attribute is used to specify where to open the linked document. It works only when href attribute is present in the area elements. Syntax: &lt;area target="_blank|_self|_parent|_top|framename"&gt; Attribute Values: _blank: It opens the link in a new window._self: It is the default value. It opens the linked document in
1 min read
Which attribute is used to target the webpage to open into a new window in HTML ?
In this article, we will learn how to open a webpage in a new window using the TARGET attribute of HTML. The Target attribute of &lt;a&gt; anchor tag is used to specify the named frame or window the link will open. The &lt;a&gt; is paired tag, so both starting&lt;a&gt; tag must have closing&lt;/a&gt; tag in the HTML document. Anchor tag has many at
2 min read
HTML &lt;form&gt; target Attribute
In this article, we will see how to open the new tab in HTML using &lt;form&gt; target Attribute, along with understanding its implementation through the examples. The &lt;form&gt; target Attribute in HTML is used to specify whether the submitted result will open in the current window, a new tab, or on a new frame ie., this attribute specifies a na
2 min read
HTML | &lt;base&gt; target Attribute
The &lt;base&gt; target Attribute in HTML is used to specify the default target for all hyperlinks and forms in the webpage. This attribute could also be overridden by the use of the target attribute for each hyperlink and the Form. Syntax: &lt;base target="_blank|_self|_parent|_top|framename" &gt; Attribute Values: _blank: It opens the link in a n
1 min read
HTML | target Attribute
The HTML target Attribute is used to specify where to open the linked document. It can be used on various elements such as: HTML | &lt;a&gt; target Attribute HTML | &lt;area&gt; target Attribute HTML | &lt;base&gt; target Attribute HTML | &lt;form&gt; target Attribute Syntax: &lt;element target="_blank|_self|_parent|_top|framename"\&gt; Attribute V
1 min read
HTML | &lt;link&gt; target Attribute
The HTML &lt;link&gt; target Attribute is used to specify the window or a frame where the linked document is loaded. It is not supported by HTML 5. Syntax: &lt;link target="_blank|_self|_parent|_top|framename"&gt; 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 fr
1 min read
Article Tags :