html tutorial - target Attribute in HTML - html5 - html code - html form




Target attribute in html

Learn html - html tutorial - Target attribute in html - html examples - html programs

  • For <a>(anchor)elements and <area> elements, the target attribute defines where to open the linked document.
  • For <base> element, the target attribute defines the default target for all hyperlinks and forms in the page.
  • For <form>element, the target attribute describes a name or a keyword that specifies where to show the response that is received after submitting the form.

Syntax for target attribute in HTML:

<a target="value">

Differences between HTML 4.01 and HTML5 for target attribute:

HTML 4.01

  • The target attribute is depreciated.

HTML 5

  • The target attribute is supported.

Applies To:

Element Attribute
<a> target
<area> target
<base> target
<form> target

Attribute Values:

Value Description
_blank Opens the linked document in a new window.
_parent Opens the linked document in the parent frame
_self Opens the linked document in the same frame as it was clicked
framename Opens the linked document in a named frame
_top Opens the linked document in the full body of the window

Sample Coding for target Attribute in HTML:

Tryit<!DOCTYPE html>
<html>
   <body>
    <p>Open the link in a new tab: 
    <a href="http://www.wikitechy.com" target="_blank">Hi Wikitechy!
    </a>
    </p>
   </body>
</html>

Code Explanation for target Attribute in HTML:

target Attribute Code Explanation

  1. <a> tag specifies a hyperlink, that is used to link “wikitechy.com”.
  2. href defines the URL of the page goes to that “wikitechy.com”.
  3. target attribute defines the target for open the wikitechy.com document in a new window because the value of the target is _blank.

Output for target Attribute in HTML:

target Attribute Tag Output

  1. The output shows a “Hi Wikitechy” link.

Browser Support for target Attribute in HTML:

Yes Yes Yes Yes Yes

Tips and Notes

  • Frames and framesets are no longer supported.
  • The _parent, _top and framename attribute values are mainly used with iframes.

Related Searches to target Attribute in html