hyperlink css javascript - How to open link in new tab on html?





6 Answers

Use one of these as per your requirements.

Open the linked document in a new window or tab:

 <a href="xyz.html" target="_blank"> Link </a>

Open the linked document in the same frame as it was clicked (this is default):

 <a href="xyz.html" target="_self"> Link </a>

Open the linked document in the parent frame:

 <a href="xyz.html" target="_parent"> Link </a>

Open the linked document in the full body of the window:

 <a href="xyz.html" target="_top"> Link </a>

Open the linked document in a named frame:

 <a href="xyz.html" target="framename"> Link </a>

See MDN

window not image

I'm working on an HTML project, and I can't find out how to open a link in a new tab without javascript.

I already know that <a href="http://www.WEBSITE_NAME.com"></a> opens the link in same tab. Any ideas how to make it open in a new one?




Use target="_blank":

<a href="http://www.example.com/" target="_blank">This will open in a new window!</a>



Use the "target" attribute of the a tag and assign it to _blank. That is:

<a href="http://www.google.com" target="_blank" >Google in a New Tab or Window depending on the browser's capabilities</a>



target="_blank" attribute will do the job. Just don't forget to add rel="noopener noreferrer" to solve the potential vulnerability. More on that here: https://dev.to/ben/the-targetblank-vulnerability-by-example

<a href="https://www.google.com/" target="_blank" rel="noopener noreferrer">Searcher</a>



You can use <a href='url' target="_blank">name</a>

Example <a href='https://www.facebook.com/hackbalteamz' target="_blank">Facebook</a>




You can use <a href="#" target="_blank">Your Text</a> Hope it helped. Thanks.






Related