What is the HTML target attribute?

Overview

The target attribute in HTMLHyperText Markup Language is used to set or specify where we want to open the linked document. We can use the target attributes on the following elements listed below:

  • <a>
  • <area>
  • <base>
  • <form>

Syntax


<element target="_blank|_self|_parent|_top|framename"\>

Parameters

  • _blank: This is used to open the link in a new window.

  • _self: This is the default value. It is used to open the link in the same window.

  • _top: This is used to open the document linked in the full body.

  • _parent: This is used to open the link in the parent frameset.

  • framename: The document is opened in the specific frame name.

Example

The HTML code provided below demonstrates how to use the target attribute:

Explanation

The link is opened in the new window because the target attribute is set to _blank. We can also set the parameters according to our own choice.