HTML <a> with target Attribute

You are Here:

HTML <a> with target Attribute

The target attribute specifies where to open the linked document.

target="_self"

Opens the linked document in the same frame when a click event is triggered.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <a href="/js" target="_self">Learn Javascript</a> </body> </html>

The following example with iframe will give you a complete idea about target="_self".

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <iframe id="iframe1" src="/test/test-file-target-self"> <p>Your browser does not support iframes.</p> </iframe> </body> </html>

Attribute Values

Value Description
_self Default. Opens the linked document in the same frame when a click event is triggered.
_blank Opens the linked document in a new window.
_parent Opens the linked document in its parent frame.
_top Will breaks outside of all the frames it is nested and opens the linked document in the Entire or Complete window.

target="_blank"

Opens the linked document in a new window.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <a href="/js" target="_blank">Learn Javascript</a> </body> </html>

The following example with iframe will give you a complete idea about target="_blank".

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <iframe id="iframe1" src="/test/test-file-target-blank"> <p>Your browser does not support iframes.</p> </iframe> </body> </html>

target="_parent"

Opens the linked document in its parent frame.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <a href="/js" target="_parent">Learn Javascript</a> </body> </html>

The following example with iframe will give you a complete idea about target="_parent".

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <iframe id="iframe1" src="/test/test-file-target-parent"> <p>Your browser does not support iframes.</p> </iframe> </body> </html>

target="_top"

Will breaks outside of all the frames it is nested and opens the linked document in the Entire or Complete window.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <iframe id="iframe1" src="/test/test-file-target-top"> <p>Your browser does not support iframes.</p> </iframe> </body> </html>

Reminder

Hi Developers, we almost covered 99.5% of HTML Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in HTML.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author