target

The target attribute in HTML specifies where the linked content or form submission will be displayed, such as in the current window, a new tab, or a designated frame.

target attribute

The target attribute in HTML, used with elements like <a>, <area>, and <form>, defines where a linked document or form result should open. It controls the browsing context, allowing content to open in the same window, a new tab, or within a specific frame. You can use predefined values or custom names for frames, giving developers control over how navigation behaves on a page.

Syntax

index.html
<tagname target="_self | _blank | _parent | _top | framename" />

Example

The a target attribute
Click here to qarpeo in a new tab.
index.html
<h1>The a target attribute</h1>
<a href="https://institute.qarpeo.com" target="_blank">Click here to qarpeo in a new tab.</a>

Form

  • Show the received response in a new window or tab:
The form target attribute





index.html
<h1>The form target attribute</h1>

<form target="_blank">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>

Values

Possible values for the HTML target attribute:

  • _self: Opens the link in the same window or frame (default if no value is specified).
  • _blank: Opens the link in a new tab or window, typically used for external links.
  • _parent: Opens the link in the parent frame; if no parent frame exists, it behaves like _self.
  • _top: Opens the link in the full window, replacing any frames.
  • _framename: Opens the link in a specific frame or iframe that is named.

Applies To

The target attribute can be applied to the following HTML elements:

Conclusion

The target attribute in HTML controls where linked content or form results will open, allowing customization of browsing behavior. It supports predefined values like _self, _blank, _parent, and _top, as well as custom frame names. This attribute enhances user navigation by managing how new content is displayed.