HTML Code for Open link in new tab

Introduction

When it comes to creating web pages, there are various ways to control the behavior of links. One common requirement is to make a link open in a new browser tab or window. In HTML, this can be achieved using the target attribute.

Understanding the target attribute

The target attribute specifies where to open the linked document. Its value can be _blank, _self, _parent, or _top. To open a link in a new tab, we use the value _blank.

Using the target attribute in HTML

To make a link open in a new tab, we simply add the target attribute to the <a> (anchor) tag and set its value to _blank. Here's an example of how this is done.

Example code

<a href="https://example.com" target="_blank">Link Text</a>

Go from files to website in seconds.

Start a free trial for 7 days — no credit card required

Get Started for Free