Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • HTML Anchor target Attribute

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 671
    Comment on it

    The target attribute is used in hyperlinks. It specifies the destination of the hyperlink.

    The target attribute is used to determine where to open/load the current link, whether on the same tab, next tab, new window or new frame.

    If we do not specify the attribute in the anchor tag then it will automatically load the link in same window and tab.


    <a target="_blank|_self|_parent|_top|framename">


    Following are the attribute values:-

    • _blank
    • _self
    • _parent
    • _top

    1. _blank:-

    The _blank attribute opens the link in new tab or in new window.

    The benefit of using ('target', '_blank') is that we can check the new link without leaving the current page.

    There is back button in _blank attribute.

    If we want to open all the links into new tab automatically, then here is the Javascript code for that:-

    jQuery(document.links)   .filter(function() {     return this.hostname != window.location.hostname;   })     .attr('target', '_blank');



    <a href="#" target="_blank">Open link in new tab</a>


    Here is the link to load link in new tab or window:-


    2. _self:-

    The target="_self" attribute opens the link in the same tab or window. It is default value for this attribute.


    <a href="" target="_self">Visit Yahoo</a>


    3. _parent:-

    The target="_parent" attribute opens the link in the parent or next level of frameset.

    This attribute is not used in HTML5.


    <a href="#" target="_parent">Open link</a>


    4. _top:-

    In this the currently displayed page is replaced by the new link page. But there is a back button available.


    <a href="#" target="_top">Open link</a>





 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: