Home > Software engineering >  I don't know how to open links in a new tab in html
I don't know how to open links in a new tab in html

Time:11-30

I don't know what is the code for opening links in a new tab, I only know the code to open links in the current tab, can you give me the code?

CodePudding user response:

You can simply use window.open("url") with JavaScript to open a link in a new tab.

You can also use target="_blank" within the html tag as well if you don't want to use JS.

CodePudding user response:

In the element put target="_blank" so for example:

<a class="your-classes" href="https://yoursite.com/here" target="_blank">

CodePudding user response:

A target attribute with the value of “_blank” opens the linked document in a new window or tab.

<a href="https://www.sitename.com" target="_blank">blablabla</a>
  •  Tags:  
  • html
  • Related