HTML Questions & Answers Logo
HTML Questions & Answers Part of the Q&A Network
Q&A Logo

How can I open a link in a new browser tab safely?

Asked on Sep 16, 2025

Answer

To open a link in a new browser tab safely, you can use the <a> element with the target="_blank" attribute and add rel="noopener noreferrer" to prevent security risks like tabnabbing.
<!-- BEGIN COPY / PASTE -->
    <a href="https://example.com" target="_blank" rel="noopener noreferrer">Visit Example</a>
    <!-- END COPY / PASTE -->
Additional Comment:
  • The target="_blank" attribute opens the link in a new tab.
  • Using rel="noopener noreferrer" prevents the new page from accessing the original page's window object, enhancing security.
  • This practice is especially important when linking to external sites.

✅ Answered with HTML best practices.


← Back to All Questions
The Q&A Network