Comprehensive Analysis of HTML Target Attribute: _blank vs _new Differences and Best Practices

Nov 10, 2025 · Programming · 11 views · 7.8

Keywords: HTML | target attribute | link security

Abstract: This article provides an in-depth examination of the differences between target="_blank" and target="_new" in HTML, based on HTML5 specifications. _blank is a standard keyword that ensures links open in new tabs consistently, while _new acts as a custom window name causing multiple links to open in the same window. The discussion includes security considerations, recommending rel="noopener" to prevent malicious sites from manipulating the original page via JavaScript, with code examples and browser compatibility details.

Overview of HTML Target Attribute

In HTML, the target attribute of the <a> tag specifies where to open the linked document. According to the HTML5 specification, valid browsing context names or keywords include _blank, _self, _parent, and _top. These keywords have specific behavioral definitions, while custom names are used to identify particular browsing contexts.

Technical Differences Between _blank and _new

target="_blank" is a standard keyword defined in the HTML specification. When users click on a link, the browser creates a new tab or window to load the target URL. Each click generates a new browsing context, ensuring links open in separate tabs.

In contrast, target="_new" is not a valid HTML keyword. According to the specification, any name starting with an underscore is reserved for special keywords, making _new technically invalid. However, browsers typically treat it as a custom window name:

This behavior means multiple links using target="_new" may open in the same window rather than creating new windows for each click.

Code Examples and Behavioral Demonstration

The following code demonstrates the practical effects of both approaches:

<!-- Standard usage: opens in new tab each time -->
<a href="https://example.com" target="_blank">Open in New Tab</a>

<!-- Non-standard usage: may open multiple links in same window -->
<a href="https://example.com" target="_new">Open in _new Window</a>

In practical testing, clicking multiple target="_blank" links creates separate tabs, while multiple target="_new" links may load sequentially in the same tab, overwriting previous content.

Security Considerations and Best Practices

When using target="_blank", important security considerations arise. Links pointing to untrusted websites could allow malicious sites to manipulate the original page via the window.opener API. To prevent such attacks, it's recommended to also set the rel="noopener" attribute:

<a href="https://untrusted-site.com" target="_blank" rel="noopener">
  Open Safely in New Tab
</a>

This configuration prevents the newly opened page from accessing or modifying the original page's content through JavaScript, enhancing application security.

Specification Compatibility and Browser Support

The HTML4 standard marked the target attribute as deprecated, but this decision was reversed in HTML5, making the target attribute an official part of the specification again. All major browsers support the target attribute regardless of HTML version.

Note that some HTML validators may flag the target attribute as deprecated when using HTML4 doctypes, though this doesn't affect functionality. For projects requiring strict validation, using HTML5 doctypes is recommended.

Conclusion and Recommendations

Based on HTML specifications and practical requirements analysis, it's recommended to always use target="_blank" for opening links in new tabs. This approach:

Avoid using target="_new" as its behavior depends on browser implementation and may lead to unpredictable results, especially when handling multiple links.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.