HTML target Attribute

If this site has been useful, we’d love your support! Running this site takes time and resources, and every small contribution helps us keep creating valuable content. Consider buying us a coffee to keep things going strong!

Description

The HTML target attribute is an attribute used in anchor (<a>), area (<area>), and form (<form>) elements to specify where the linked document, or the output of a form submission, will be displayed or processed. When used, it influences the browsing context in which a document will be presented. Essentially, it can control whether a new window or tab is opened for the result, or whether the result will be displayed in the current or a specific frame within the web page. The value assigned to this attribute determines the name of the browsing context which will be used. There are predefined keyword values that can direct the browser in specific ways, but custom names for frames or windows can also be used to achieve more tailored behaviors. The use of this attribute enhances user navigation on a website by controlling how new information is presented to them, whether within the same window, in a new tab, or even in an iframe, depending on the setup of the web page's structure and the goals of the web designer.

Syntax

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

Values

  • _selfOpens the document in the same frame or window as the link that was clicked. This is the default behavior if the target attribute is not specified.
  • _blankOpens the document in a new window or tab. This is commonly used for external links to ensure the user does not navigate away from the original page.
  • _parentOpens the document in the parent frame of the frame where the link is placed. If there's no parent, this option behaves the same as _self.
  • _topOpens the document in the full body of the window, breaking out of any framesets. It ensures the linked document takes over the entire window.
  • framenameIf you have named frames or iframes on your page, you can use the target attribute to specify that a link should open in a particular frame by naming it.

Applies To

The target attribute can be used on the following html elements.

Example

<a href="https://www.google.com" target="_blank">Click here to Google in a new tab.</a>

Browser Support

The following table will show you the current browser support for the HTML target Attribute.

Desktop
Edge Chrome Firefox Opera Safari
YesYesYesYesYes
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
YesYesYesYesYesYes

Last updated by CSSPortal on: 29th March 2024