HTML <a> Label's Target Properties
HTML <a> Tags
Definition and usage
The target property of the <a> tag specifies where to open the linked document.
If a target property is included in a <a> tag, the browser will load and display the document in the frame or window that is named after the href attribute of the tag, which matches the target name. If the frame or window that specifies the name or ID does not exist, the browser opens a new window, gives the window a specified tag, and then loads the new document into that window. From then on, the hyperlinked document can point to this new window.
Open a new window
The hyperlinks that are directed make it easy to create efficient browsing tools. For example, a simple list of content documents can redirect the document to a separate window:
<ul>
<li><a href= "pref.html" target= "View_window" >Preface</a></li>
<li><a href= "chap1.html" target= "View_window" >chapter 1</a></li>
<li><a href= "chap2.html" target= "View_window" >chapter 2</a></li>
<li><a href= "chap3.html" target= "View_window" >chapter 3</a></li>
</ul>
Try it yourself.
When a user selects a link in the table of contents for the first time, the browser opens a new window, marks it as "View_window", and then displays the document content that you want to display. If the user selects another link from this list of contents, and the "View_window" is still open, the browser will then load the selected document into that window again, replacing the documents just now.
Throughout the process, the window containing the table of contents is accessible to the user. You can change the contents of another window by clicking one of the connections in the window.
Open a window in the frame
Instead of opening a full browser window, using target is a more common way to direct hyperlink content to one or more frames in a <frameset> display. You can put this table of contents in one of the frames of a document with two frames and use the adjacent frame to display the selected document:
<frameset cols= "100,*" >
<frame src= "toc.html" >
<frame src= "pref.html" name= "View_frame" >
</frameset>
Try it yourself.
When the browser initially displays both frames, the left frame contains a table of contents, and the frame on the right contains the preface.
This is the source code for "toc.html":
<ul>
<li><a href= "pref.html" target= "View_frame" >Preface</a></li>
<li><a href= "chap1.html" target= "View_frame" >chapter 1</a></li>
<li><a href= "chap2.html" target= "View_frame" >chapter 2</a></li>
<li><a href= "chap3.html" target= "View_frame" >chapter 3</a></li>
</ul>
Note that in the document "Toc.html", the target of each link is "View_frame", which is the frame on the right.
When a user selects a link from a directory in the left frame, the browser loads the associated document and displays it in the "View_frame" frame on the right. When other links are selected, the contents of the frame on the right are also changed, and the left frame remains unchanged.
Special goals.
There are 4 reserved target names to use for special document redirection operations:
_blank
The browser always loads the target document in a newly opened, unnamed window.
_self
The value of this target is the default target for all <a> tags that do not have a target specified, which causes the target document to be loaded and displayed in the same frame or window as the source document. This goal is superfluous and unnecessary unless used with the target property in the document title <base> tag.
_parent
This goal causes the document to be loaded into the parent window or the frameset that contains the frame referenced by the hyperlink. If the reference is in a window or in a top-level frame, then it is equivalent to the target _self.
_top
This goal causes the document to be loaded into the window containing the hyperlink, with the _top target clearing all the contained frames and loading the document into the entire browser window.
Tip: All 4 values of these target begin with an underscore. Any other window or target that starts with an underscore will be ignored by the browser, so do not underline the first character of any frame name or ID defined in the document.
Grammar
<a target= "value">
Property value
Value |
Describe |
_blank |
Opens the linked document in a new window. |
_self |
Default. Open the linked document in the same frame. |
_parent |
Opens the linked document in the parent frameset. |
_top |
Opens the linked document throughout the window. |
FrameName |
Opens the linked document in the specified frame. |
HTML <a> Tags
Target property for HTML <a> tags