Home / Articles / Programming languages / Markup languages / HTML & CSS / Parameter target in HTML

Parameter target in HTML

Parameter target in HTML
 
Parameter target in HTML
  • Currently 0 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 0/5 (0 votes cast)

Thank you for rating!

You have already rated this page, you can only rate it once!

Your rating has been changed, thanks for rating!

Log in or create a user account to rate this page.


By default, if you click on a link a document opens in the current window or frame. If necessary, this can be changed by setting parameter target in the a tag. This parameter can have the following values:

  • _blank - loads the page in a new browser window;
  • _self - loads the page in the current window;
  • _parent - loads the page in the parent frame;
  • _top - closes all frames and loads the page in a full browser window.

Example 1 shows how to create a link to a website that opens in a new window.

Example 1. Opening document in a new window.

<a href="http://www.google.com" target="_blank">Link opens a new window to site www.google.com</a>

If a site uses frames, then you can use the name of the frame as target's value (example 2).

Example 2. Opening document in a frame.

<a href="http://www.google.com" target="newframe">site www.google.com</a>

The link in the example 2 opens site www.google.com, which in turn opens in a frame with the name "newframe".

Note: if the parameter target has unknown value, for example, name of the frame has an error, then this causes the link to open a new window.

If you need to set your web page, to open all links in a new window, then there is no need to add to every tag a parameter target="_blank". The code can be reduced if in the beginning of the page you add string <base target="_blank">, as shown in example 3.

Example 3. Using the tag base.

<base target="_blank">
<a href="1.php">Link will open in a new window</a>
<a href="2.php" target="_self">Link will open in the current window</a>

In order for the link to open in the current window, add the tag a with the parameter target="_self", as shown in this example.


 

Read also

How to create a link in HTML

How to create a link in HTML

Image as a link in HTML

Image as a link in HTML

Links within a page in HTML

Links within a page in HTML

Post comment

basicuse.net
html5_css
106160485398655174790

Quick navigation

General navigation