Ask coding questions

← Back to all posts
HTML Link Open in a New Tab
IOP3 (848)

HTML Link Open in a New Tab

Since when you use the <a> tag for links and you press on one, it will replace the webpage with where the link led you too.

I'm wondering is there a way to open the link in a new tab, so it doesn't replace the old tab?


Answered by OldWizard209 (1702) [earned 5 cycles]
View Answer
OldWizard209 (1702)

You can use the target attribute and set it to blank:

This will open on a New Tab.


<button onclick="'___.html')">button name</button>


I said for button


@KSUDEE I said for the button

LegendaryWolf (572)

I had the same question! ty

tussiez (1693)

A Solution

SameeraMurthy (109)

The Solution

Use the target attribute to open links in a new tab.
Like this:

Hope this helped



you have to use target. You can assign it to blank, and it opens it up.

like that.
That should work