Horje
Which attribute is used to target the webpage to open into a new window in HTML ?

HTML (Hyper Text Markup Language) plays the most significant role in website development. But when it comes to good user experience and easy navigation then the <a> tag is used. In this article, we will discuss the hyperlink tag, its possible attributes, and how a user can open a web page in a new window in HTML.

Introduction

The target attribute in HTML states where to open the linked document. It is an attribute of the <a> (anchor) tag, which is used to define hyperlinks. The target attribute determines whether the link will open in the same window, a new window, or a specific frame.

The <a> is a paired tag, so both starting <a> and closing tag </a> in HTML document Ancher has many attributes but href (hypertext reference) the mandatory as it specifies the destination URL of the webpage the link will move to.

The target attributes are specifying that the multiple ways a user can open web pages.

Syntax:

<a href="URL" target="_top"> Linked Text </a>

Types of Target Attributes

This attribute refers to the target window for the URL mentioned with href attribute. It can take the following possible values:

  • _top: It loads the webpage into a browser window using full body i.e. by replacing existing frames.
  • _self: By default, _self is the value for the target attribute. It loads the webpage in the same window/frame from which the link is clicked.
  • _blank: It loads the webpage in a new window of the browser.
  • _parent: It loads the webpage in the parent window/frameset.

How to open webpage into a new window in HTML?

If we want to load the web page content in a new tab/window, then we have to use <a> tag and inside <a> tag set the target attribute as “_blank” as like given in bellow example below. Then the web page will open in a new window on the user’s click.

Example:

The below example describes the use of target=”_blank”. When a user clicks on the linked text the webpage will open up in the new window. 

HTML
<!DOCTYPE html>
<html>

<head>
    <title>TARGET ATTRIBUTE</title>
</head>

<body>
    <h2 style="color:green;">TARGET ATTRIBUTE</h2>
    <a href="/archive/" target="_blank">
        Click here to visit Geeks website</a>
</body>

</html>

Output:

TARGETBLANKIMG

target_blank

Conclusion

By using the target attribute “_blank” in HTML the developers can specify whether a link opens in a new window and it helps users navigate the website easily .




Reffered: https://www.geeksforgeeks.org


HTML

Related
What is the use of WebSocket API ? What is the use of WebSocket API ?
What is Web CORS in HTML5 ? What is Web CORS in HTML5 ?
HTML DOM Input URL blur() Method HTML DOM Input URL blur() Method
HTML DOM Screen Object HTML DOM Screen Object
HTML DOM Input Text blur() Method HTML DOM Input Text blur() Method

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
11