# Bad value X for attribute “name” on element “iframe”: Browsing context name started with the underscore.

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-x-for-attribute-name-on-element-iframe-browsing-context-name-started-with-the-underscore
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

In HTML, the `name` attribute on an `<iframe>` defines a **browsing context name**. This name can be referenced by other elements — for example, a link with `target="my-frame"` will open its URL inside the `<iframe>` whose `name` is `"my-frame"`. The HTML specification reserves all browsing context names that start with an underscore for special keywords:

- `_self` — the current browsing context
- `_blank` — a new browsing context
- `_parent` — the parent browsing context
- `_top` — the topmost browsing context

Because the underscore prefix is reserved for these (and potentially future) keywords, the spec requires that any **custom** browsing context name must **not** begin with `_`. Setting `name="_example"` or `name="_myFrame"` on an `<iframe>` is invalid HTML, even though those exact strings aren't currently defined keywords. Browsers may handle these inconsistently — some might ignore the name entirely, while others could treat it as one of the reserved keywords, leading to unexpected navigation behavior.

This matters for several reasons:

- **Standards compliance:** The WHATWG HTML living standard explicitly states that a valid browsing context name must not start with an underscore character.
- **Predictable behavior:** Using a reserved prefix can cause links or forms targeting that `<iframe>` to navigate in unintended ways (e.g., opening in a new tab instead of within the frame).
- **Future-proofing:** New underscore-prefixed keywords could be added to the spec, which might break pages that use custom names starting with `_`.

To fix the issue, simply rename the `name` attribute value so it doesn't start with an underscore. You can use underscores elsewhere in the name — just not as the first character.

## Examples

### ❌ Invalid: name starts with an underscore

```html
<iframe src="https://example.com" name="_example"></iframe>

<a href="https://example.com/page" target="_example">Open in frame</a>
```

The name `_example` starts with an underscore, which makes it invalid. A browser might interpret `_example` unpredictably or ignore the name entirely when used as a `target`.

### ✅ Fixed: underscore removed from the start

```html
<iframe src="https://example.com" name="example"></iframe>

<a href="https://example.com/page" target="example">Open in frame</a>
```

### ✅ Fixed: underscore used elsewhere in the name

```html
<iframe src="https://example.com" name="my_example"></iframe>

<a href="https://example.com/page" target="my_example">Open in frame</a>
```

Underscores are perfectly fine as long as they aren't the **first** character.

### ❌ Invalid: using a reserved keyword as a frame name

```html
<iframe src="https://example.com" name="_blank"></iframe>
```

Using `_blank` as an `<iframe>` name is also invalid because it's a reserved browsing context keyword. A link targeting `_blank` would open in a new window/tab rather than inside this `<iframe>`, which is almost certainly not what you intended.

### ✅ Fixed: descriptive name without underscore prefix

```html
<iframe src="https://example.com" name="content-frame"></iframe>

<a href="https://example.com/page" target="content-frame">Open in frame</a>
```

## How to fix

1. Find every `<iframe>` element whose `name` attribute starts with `_`.
2. Rename each one by removing the leading underscore or replacing it with a letter or other valid character.
3. Update any `target` attributes on `<a>`, `<form>`, or `<base>` elements that reference the old name so they match the new name.
4. Re-validate your HTML to confirm the issue is resolved.
