HTML Links – Target Attribute
The target attribute in the <a> tag specifies where to open the linked document. It controls whether the link opens in the same window, a new window, or a specific frame.
|
Attribute |
Description |
|
|
|
|
_blank |
Opens the linked document in a new window or tab. |
|
|
|
|
_self |
Opens the linked document in the same frame or window as the link. (Default behavior) |
|
|
|
|
_parent |
Opens the linked document in the parent frame. |
|
|
|
|
_top |
Opens the linked document in the full body of the window. |
|
|
|
|
framename |
Opens the linked document in a specified frame. The frame’s name is specified in the attribute. |
In this example we demonstrates the use of target attributes in links. Each link opens in a different context: _blank opens in a new window or tab, _self in the same frame, _parent in the parent frame, _top in the full window body, and framename in a specified frame.
<!DOCTYPE html>
<html>
<head>
<title>Target Attribute Example</title>
</head>
<body>
<h3>
Various options available in the
Target Attribute
</h3>
<p>
If you set the target attribute to “_blank”, the link will open in a new browser window or tab.
</p>
<a href=”https://www.cssunitarai.org//////” target=”_blank”>
Sunitacscorner
</a>
<p>
If you set the target attribute to “_self”, the link will open in the same window or tab.
</p>
<a href=”https://www.cssunitarai.org//////” target=”_self”>
Sunitacscorner
</a>
<p>
If you set the target attribute to “_top”, the link will open in the full body of the window.
</p>
<a href=”https://www.cssunitarai.org//////” target=”_top”>
Sunitacscorner
</a>
<p>
If you set the target attribute to “_parent”, the link will open in the parent frame.
</p>
<a href=”https://www.cssunitarai.org//////” target=”_parent”>
Sunitacscorner
</a>
</body>
</html>