Skip to content

Open link in new tab

Intro

One thing that many sites do is make their external links open in new tabs. You don’t have to do this, but it is fairly common.

Steps

Add target attribute

To make the external link open in a new tab, add the target attribute with the value of _blank.

<a href="about.html">About</a>
<a href="https://example.com/" target="_blank">External link</a>

Make sure you have your preview open in an actual browser. Click on the link to see it open up in a new tab.

There are some instances where you might want to add target="_blank" to internal links as well, but it’s more commonly used with external links so that users always have your website open up in one tab.

Final code

Check the last code snippet for the code that should be in between the body tags.