Target attribute in anchor tag, Use of target attribute of anchor tag in HTML5.


 

Target attribute in anchor tag, Use of target attribute of anchor tag in HTML5.

In this section, we will see the use of target attribute of anchor tag in HTML5.

In this section, we will see the use of target attribute of anchor tag in HTML5.

Target attribute in anchor tag, Use of target attribute of anchor tag in HTML5.

In this tutorial, we will see the use of target attribute of anchor tag in HTML5. Target attribute tells the browser where to display linked document. There are four defined targets. Each target starts with an underscore("_").
_blank, _parent, _self, _top.

Target Attribute :
Attribute Value Description
target _blank
_self
_parent
_top
linked document will be display in new window.
linked document will be display in current window.
linked document will be display in current frameset.
linked document will be display in main browser window. 


Declaration Syntax :

Declaration syntax of target attribute in anchor tag.

                  <a  href="value" target="value">Text Area</a>

Example of target attribute:

Code:

hrefAttributeTag.html

<!DOCTYPE html>
<html>
<head>
<title>Write title of document.</title>
</head>
<body>
<p>Target attribute of anchor tag in HTML5.</p>
<ul>
<li>
<a href="http://www.roseindia.net/" target="_blank">
Open in 
new window.</a>
</li>
<li>
<a href="http://www.roseindia.net/" target="_self">
Open in current window.</a>

</li>
</ul>
</body>
</html>
Output:

 

Note: See the browser compatible page for successfully rendering the program.

Download this code

Ads