HTML a Tag target Attribute Tutorial

In this section, we will learn what target attribute is and how it works.

What is target Attribute in HTML <a> Tag?

When we click on a link, the linked document might be opened in the same window that the current document is and replace it or, it might open a new tab or window depending on the default behavior of browsers.

But with the target attribute of the HTML <a> element, we can take the control of where to open the target document.

Basically, this attribute has values that allow us to specify where exactly the target document should be opened independent from browsers default behavior.

HTML target Attribute in <a> Tag Syntax:

<a target= "_blank | _self | _parent | _top | framename">

<a> Tag target Attribute Values

In the table below, you can see the list of values for the target attribute

Name Description
_blank Open the linked document on a new tab or window.
_self Open the linked document on the window of the current document.
_parent Open the linked document on the parent frame
_top Open the linked document on the full body of the window
framename Open the linked document on the specified iframe.

Example: using target attribute in HTML <a> tag

<!DOCTYPE html>
<html>
<head>
<title>HTML is fun :)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<a href="https://www.enjoydeveloping.com" target="_blank">www.enjoydeveloping.com</a>
</body>
</html>