# Bad value X for attribute “target” on element “a”: Reserved keyword X used.

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-x-for-attribute-target-on-element-a-reserved-keyword-x-used
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `target` attribute specifies where to display the linked resource. The HTML specification defines a set of reserved keywords that all begin with an underscore: `_blank`, `_self`, `_parent`, and `_top`. Any other value starting with an underscore is considered invalid because the underscore prefix is reserved for current and future keywords defined by the specification.

This matters for several reasons. First, browsers may handle unrecognized underscore-prefixed values inconsistently — some might treat them like `_blank`, while others might ignore them entirely or treat them as named browsing contexts. This leads to unpredictable behavior across different browsers. Second, using reserved but undefined keywords signals a likely typo or misunderstanding of the attribute, which could cause navigation to behave differently than intended. Standards compliance ensures your links work reliably for all users.

The valid keywords and their meanings are:

- `_self` — Opens the link in the current browsing context (the default behavior).
- `_blank` — Opens the link in a new, unnamed browsing context (typically a new tab).
- `_parent` — Opens the link in the parent browsing context, or `_self` if there is no parent.
- `_top` — Opens the link in the topmost browsing context, or `_self` if there is no ancestor.

If you need to target a specific named frame or window, simply use a name **without** a leading underscore. Any string that doesn't start with `_` is treated as a valid named browsing context.

## Examples

### Incorrect: Invalid reserved keyword

These examples use underscore-prefixed values that are not recognized keywords:

```html
<!-- Typo: "_blanks" is not a valid keyword -->
<a href="https://example.com" target="_blanks">Example</a>

<!-- "_new" is not a valid keyword -->
<a href="https://example.com" target="_new">Open in new tab</a>

<!-- "_tab" is not a valid keyword -->
<a href="https://example.com" target="_tab">Open link</a>
```

### Correct: Using a valid keyword

```html
<!-- Use "_blank" to open in a new tab -->
<a href="https://example.com" target="_blank">Example</a>

<!-- Use "_self" to open in the same tab (also the default) -->
<a href="https://example.com" target="_self">Example</a>

<!-- Use "_parent" to open in the parent frame -->
<a href="https://example.com" target="_parent">Example</a>

<!-- Use "_top" to open in the topmost frame -->
<a href="https://example.com" target="_top">Example</a>
```

### Correct: Using a custom named browsing context

If you intend to target a specific named window or frame rather than using a keyword, remove the underscore prefix:

```html
<!-- Valid: "myframe" is a custom browsing context name -->
<a href="https://example.com" target="myframe">Open in myframe</a>

<!-- Valid: targeting a named iframe -->
<iframe name="content-frame" src="about:blank"></iframe>
<a href="https://example.com" target="content-frame">Load in iframe</a>
```

A common mistake is using `_new` with the intention of opening a link in a new tab. While some browsers may treat `_new` similarly to `_blank`, it is not a valid keyword. Use `_blank` instead. Note that when using `target="_blank"`, it's a good security practice to also include `rel="noopener"` (though modern browsers now do this by default):

```html
<a href="https://example.com" target="_blank" rel="noopener">Example</a>
```
