YouTip LogoYouTip

Att A Target

# HTML `` target Attribute The `target` attribute of the HTML anchor (``) tag specifies where to open the linked document. By default, browsers open the linked page in the current window or tab. Using the `target` attribute allows you to change this behavior, such as opening the link in a new tab, a parent frame, or a specific named iframe. --- ## Quick Example The following example demonstrates how to open a link in a new browser tab or window using `target="_blank"`: ```html Visit Wikipedia! ``` --- ## Browser Support The `target` attribute is fully supported by all modern web browsers: * Google Chrome * Mozilla Firefox * Microsoft Edge / Internet Explorer * Safari * Opera --- ## Syntax ```html ``` --- ## Attribute Values | Value | Description | | :--- | :--- | | `_blank` | Opens the linked document in a new window or tab. | | `_self` | **Default.** Opens the linked document in the same frame/tab as it was clicked. | | `_parent` | Opens the linked document in the parent frame. | | `_top` | Opens the linked document in the full body of the window (breaks out of all frames). | | *framename* | Opens the linked document in a custom named ` ``` --- ## Security and Performance Considerations When using `target="_blank"`, always consider security and performance implications: ### The Security Risk (`noopener` and `noreferrer`) When you link to another page using `target="_blank"`, the destination page gains partial access to the linking page's window object via `window.opener`. This exposes your site to potential phishing attacks (known as "tabnabbing"). To prevent this, always include `rel="noopener"` or `rel="noreferrer"` alongside `target="_blank"`: ```html Secure External Link ``` * **`noopener`**: Prevents the newly opened page from accessing `window.opener` and ensures it runs in a separate process, improving performance. * **`noreferrer`**: Does the same as `noopener` and also prevents the browser from sending the referrer header to the destination website. > **Note:** Modern browsers (such as Chrome 88+, Firefox 79+, and Safari 12.1+) automatically apply `rel="noopener"` behavior to any `target="_blank"` links by default. However, explicitly adding it remains a best practice for backward compatibility.
← Att A TypeAtt A Shape β†’