# The “name” attribute on the “embed” element is obsolete. Use the “id” attribute instead.

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

Replace `name` on an `<embed>` element with `id`, or delete it if nothing refers to it.

The `name` attribute on `<embed>` dates from the plugin era, when pages named a Flash movie or other plugin content so a script could find it. The HTML standard lists it among the obsolete attributes and points to `id` as the way to identify the element. The validator reports this warning together with a second message saying that `name` is never allowed on `<embed>`. Both point at the same attribute, and the same change fixes both.

Before you rename it, search your scripts and stylesheets for the old name. Code that looked the element up by name should call `document.getElementById()` with the new `id`, and an `id` must be unique in the document. If no code uses the name, remove the attribute and leave the `id` out.

## Invalid example

```html
<embed src="sales-chart.svg" type="image/svg+xml" name="sales" width="600" height="400">
```

## Valid example

```html
<embed src="sales-chart.svg" type="image/svg+xml" id="sales" width="600" height="400">
<script>
  const chart = document.getElementById("sales");
</script>
```
