HTML target Attribute

❮ HTML Attributes

Example

<a href="https://www.google.com" target="_blank">Visit google.com!</a>

Meaning

The target attribute specifies where to open the linked document for <a> and <area> elements, the default target for all hyperlinks and forms in the page for <base> elements, and the target frame that will display the results of a form submission for <form> elements.




Standard Syntax

<element target="_self|_blank|_parent|_top|frameName">



Browser Support




Status




Applies to:

The target attribute can be used on the following element:

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






Attribute Values

Value Description
_self Opens the link in the same window as it was clicked by user (default)
_blank Opens the link in a new window or tab, but users can configure browsers to open a new window instead.
_parent Opens the link in the parent frame. If no parent, behaves as _self.
_top Opens the link in the full body of the window. If no ancestors, behaves as _self.
frameName Opens the link in the specified iframe



More Examples

<area> Tag Example

<img src="img/desk.jpg" usemap="#image-map">

<map name="image-map">
    <area target="_blank" alt="Computer" title="Computer" href="img/computer.png" coords="365,99,905,783" shape="rect">
    <area target="_blank" alt="Cup" title="Cup" href="img/cup.png" coords="1047,672,97" shape="circle">
    <area target="_blank" alt="Mobile" title="Mobile" href="img/mobile.png" coords="960,385,1040,541" shape="rect">
    <area target="_blank" alt="Book" title="Book" href="img/book.png" coords="175,426,96,527,20,664,232,755,298,628,364,505" shape="poly">
</map>



<base> Tag Example

Example

<head>
	<base href="img/" target="_blank">
</head>
<body>
	<img src="image.jpeg" width="50" height="50" alt="demo">
</body>



<form> Tag Example

<form target="_blank" action="action.php" method="get">
	<label for="fname">First name:</label>
	<input type="text" id="fname" name="fname"><br>
	<label for="lname">Last name:</label>
	<input type="text" id="lname" name="lname"><br>
	<input type="submit" value="Submit">
</form>
❮ HTML Attributes