HTML target Attribute


The target attribute functions with both the <a> tag and <form> to determine where a linked document should open.

html-target-attribute


Syntax

 <a href="URL" target="value">Link Text</a>

Common Values for target

Value Description
_self Default. Opens link in the same tab/window
_blank Opens link in a new tab/window
_parent Opens link in the parent frame (if using frames)
_top Opens link in the full body of the window, breaking out of frames
framename Opens the link in a named iframe (used with <iframe name="framename">)

Example: Open in the Same Tab (default)

<a href="about.html" target="_self">About Us</a>
 

Opens about.html in the same tab.

 


Example: Open in a New Tab

 <a href="https://www.example.com" target="_blank">Visit Example</a>

Example: Link in an Iframe

<iframe src="home.html" name="myframe" width="400" height="300"></iframe>

<a href="about.html" target="myframe">Load About Page in Frame</a>

Loads about.html inside the iframe named myframe.

 




OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.