Horje
HTML target Attribute

Definition and Usage

For <a> and <area> elements, the target attribute specifies where to open the linked document.

For <base> elements, the target attribute specifies the default target for all hyperlinks and forms in the page.

For <form> elements, the target attribute specifies a name or a keyword that indicates where to display the response that is received after submitting the form.


Applies to

The target attribute can be used on the following elements:

Elements Attribute
<a> target
<area> target
<base> target
<form> target

Browser Support

The target attribute has the following browser support for each element:


How to use The target attribute specifies where to open the linked document - HTML target Attribute

A Example. The a target attribute. Open link in a new window or tab.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The a target attribute</h1>

<p>Open link in a new window or tab: <a href="https://horje.com" target="_blank">Visit Horje!</a></p>

</body>
</html>

Output should be:

How to use The target attribute specifies where to open the linked document - HTML target Attribute

How to add An image map, with clickable areas, and a target attribute - HTML target Attribute

Area Example. The area target attribute. Click on the sun or on one of the planets to watch it closer.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The area target attribute</h1>

<p>Click on the sun or on one of the planets to watch it closer:</p>

<img src="https://horje.com/avatar.png" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm" target="_blank">
  <area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">
  <area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>

</body>
</html>

Output should be:

How to add An image map, with clickable areas, and a target attribute - HTML target Attribute

How to Specify a default target for all hyperlinks and forms on a page - HTML target Attribute

Base Example. Notice that the link opens in a new window, even if it has no target="_blank" attribute. This is because the target attribute of the base element is set to "_blank".
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <base target="_blank">
</head>
<body>

<h1>The base target attribute</h1>

<p><a href="https://horje.com">Horje</a> - Notice that the link opens in a new window, even if it has no target="_blank" attribute. This is because the target attribute of the base element is set to "_blank".</p>

</body>
</html>

Output should be:

How to Specify a default target for all hyperlinks and forms on a page - HTML target Attribute

How to Display the response received in a new window or tab - HTML target Attribute

Form Example. The form target attribute.
index.html
Example: HTML
<form action="/action_page.php" method="get" target="_blank">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>

Output should be:

How to Display the response received in a new window or tab - HTML target Attribute




html target attribute

Type:
Develop
Category:
Web Tutorial
Sub Category:
HTML Attribute
Uploaded by:
Admin


Read Article
https://develop.horje.com/learn/1434/reference