To make a link open in a new tab in HTML, you need to add the target
attribute to the <a>
tag and set its value to _blank
.
Here's an example:
<a href="https://www.example.com" target="_blank">Visit Example Website</a>
This will create a link that, when clicked, will open the specified website (https://www.example.com
) in a new tab or window.
Here are some additional points to consider:
- Using
target="_blank"
: This is the most common method to open a link in a new tab. - Browser Behavior: The way
target="_blank"
works can vary slightly across different browsers. However, it generally opens the link in a new tab or window. - Security Considerations: Using
target="_blank"
can sometimes pose security risks, especially if you're linking to untrusted websites. It's important to be aware of this and to use it carefully.