# The “name” attribute is never allowed on the “b” element.

> Canonical HTML version: https://rocketvalidator.com/html-validation/the-name-attribute-is-never-allowed-on-the-b-element
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `name` attribute is not a valid attribute for the `<b>` element in HTML.

`<b>` only takes the global attributes, and `name` is not one of them. HTML defines `name` on a handful of elements, mostly form controls, `<form>`, `<iframe>` and `<meta>`. The validator reports it twice on `<b>`: this warning, and an error saying that the attribute is not allowed on `b` at this point. Removing the attribute clears both.

`name` on `<b>` is often left over from an old anchor pattern. `<a name="...">` used to mark a spot that links could jump to, and people copied the attribute onto other elements. It doesn't work there. To resolve a fragment such as `#shipping`, browsers look for an element with that `id`, and the only `name` they check is the one on `<a>`. So a link to `#shipping` won't scroll to `<b name="shipping">`.

Change `name` to `id` and the link works, as long as the value is unique on the page. If the value is only there for scripts, put it in a `data-*` attribute such as `data-name`, and update any script that finds the element with `document.getElementsByName()` to use `getElementById()` or a `[data-name]` selector.

## Invalid example

```html
<p><a href="#shipping">Shipping costs</a></p>
<p><b name="shipping">Shipping</b> is free on orders over 50 euros.</p>
```

## Valid example

```html
<p><a href="#shipping">Shipping costs</a></p>
<p><b id="shipping">Shipping</b> is free on orders over 50 euros.</p>
```
