How to define link targets with _target in HTML

With _target link targets are defined in HTML. Although target _blank in HTML provides the option of opening hyperlinks in a new window, this option is also viewed critically. The default setting _self, on the other hand, causes visitors to leave the current website.

$1 Domain Names

Register great TLDs for less than $1 for the first year.

Why wait? Grab your favorite domain name today!

  • Matching email
  • SSL certificate
  • 24/7/365 support

What is _target?

For dealing with hyperlinks on your website, the HTML attribute target is an important tool. Namely, with this attribute you create the target window of a link. If a visitor clicks on a link on your website, the new page will open in the current tab or window by default. If you don’t want this, you can use _target to specify that the link should open in a new tab or on a second page. This has the advantage that visitors stay on your online presence longer and do not leave it for another website.

However, there is also criticism of this practice. If visitors to your website have not made any other settings, you are interfering with their user behavior and opening a new page or tab without them requesting it. For this reason, this option was temporarily not allowed and returned only in HTML 5. It is now recommended that you use the corresponding command in HTML called target _blank only when leaving your page would result in data loss. Thus, the command is for the benefit of users. You will learn how _target works later in this text.


You want to learn HTML? Our beginner tutorial will help you!

What is the syntax of _target in HTML?

The HTML attribute target is usually enclosed in the HTML tag and must contain a fixed value. Other allowed elements for _target are area, base and form. When written out, it looks like this, for example:

<a href="" target="_parent">

What values are allowed for _target?

_target may contain the following values:

Value Description
_self _self is the default and requires the link to open in the same tab or page.
_blank _blank causes the hyperlink to open in a new tab or a different window.
_parent _parent causes the hyperlink to open in the parent window.
_top With _top the linked document will be opened in a whole window.
<name> With this option you can open the document in a defined iframe.  

How is _target used in HTML?

_Target is placed inside an element. It looks like this in the code:

_self in code

_self is set as default. If you want to set the value manually, this is the code:

<a href="" target="_self">Click here</a>.

target _blank in HTML

target _blank in HTML makes the link open in a new window or tab. If you use this value, you should add rel="noopener" for security reasons. Although this is not a must from a technical point of view, it is highly recommended, as it prevents the linked page from potentially accessing usage data. In the code it looks like this:

<a href="" target="_blank" rel="noopener">Click here</a>.

Now the corresponding link will open in a new tab.

Open links in a specified iframe

If you have precisely defined the name of a window in your frameset, you can also have the page open in it. If this option does not work because the name does not exist, a new tab will be opened automatically as in the HTML target _blank variant.

<a href="" target="Defined window">Click here</a>.

A website made according to your wishes! IONOS provides everything you need to tailor your own website to your requirements with its Website Builder. You are free to decide whether you want to build the website yourself or whether you prefer to rely on our team of experts who will create the site in close coordination with you.

Was this article helpful?
We use cookies on our website to provide you with the best possible user experience. By continuing to use our website or services, you agree to their use. More Information.
Page top