The target
attribute on a link specifies where to open the linked page.
Options include: the same tab, a new tab, a new window, or in an iframe.
Elements that accept this attribute include <a>, <area>, <form>, and <base>.
A target attribute on an <a> tag.
The linked page will display in a new browser tab.
Go to <a target="_blank"
href="https://google.com/">Google</a>
For additional details see our HTML anchor target Reference.
The target
attribute specifies the tab or window in which the linked page or the form response will open.
A linked page can be opened in the same tab, a new tab, a new window, or an iframe.
If target
is not set, the link will open in the same tab/window as the current page.
<tagname target="_self | _blank | _parent | _top | framename" />
Value | Description |
---|---|
_self | Opens the page in the same tab/window. This is the default. |
_blank | Opens the page in a new tab. |
_parent | Opens the page in the parent iframe. In the same iframe if there is no parent. |
_top | Opens the page in the top level frame which always is the full browser tab/window. |
framename | Opens the page in a named iframe. |
These elements accept the target
attribute.
Elements | Description | |
---|---|---|
<a> | Specifies an anchor link -- see example above | |
<area> | Creates a clickable area inside an image map. | |
<form> | Specifies an HTML form. | |
<base> | Sets the base URL for all relative URLs on a page or site. |
A target attribute on an <area> element.
Clicking the monitor area will open a linked page in a new browser tab.
<img src="/img/html/computer-map.png" alt="Computer" usemap="#computermap">
<map name="computermap">
<area target="_blank" shape="rect" coords="253,142,16,2"
alt="monitor" href="https://google.com/search?q=monitor">
</map>
For additional details see our HTML area target Reference.
A target attribute on a <form> element.
Submitting the form will open a new browser tab.
<form action="/tutorial/action.html" target="_blank">
<input type="text" name="firstname" placeholder="First name">
<input type="text" name="lastname" placeholder="Last name">
<button type="submit">Submit</button>
</form>
For additional details see our HTML form target Reference.
A target attribute on a <base> element.
With this base element, all links on the page will open in a new browser tab.
<head>
<base target="_blank" href="https://en.wikipedia.org/wiki/">
</head>
<nav>
<a href="Vincent_van_Gogh">Vincent Van Gogh</a> <br />
<a href="Henri_Matisse">Henri Matisse</a> <br />
<a href="Paul_Cézanne">Paul Cézanne</a>
</nav>
For additional details see our HTML base target Reference.
Here is when target
support started for each browser:
Chrome
|
1.0 | Sep 2008 |
Firefox
|
1.0 | Sep 2002 |
IE/Edge
|
1.0 | Aug 1995 |
Opera
|
1.0 | Jan 2006 |
Safari
|
1.0 | Jan 2003 |