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?

@IcingHackz

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

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

This will open on a New Tab.

KSUDEE (0)

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

KSUDEE (0)

I said for button

KSUDEE (0)

@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

RYANTADIPARTHI (6060)

Solution

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

like that.
That should work