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

> Canonical HTML version: https://rocketvalidator.com/html-validation/the-name-attribute-is-never-allowed-on-the-table-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 `<table>` element in HTML.

The `name` attribute was never part of any HTML specification for tables. Some older browsers tolerated it as a way to create anchor targets, but validators reject it because it does not belong on `<table>`. If the goal is to link directly to a table, use the `id` attribute instead. The `id` attribute is a global attribute, valid on any HTML element, and works as a fragment identifier in URLs (e.g., `page.html#prices`).

If the `name` attribute was being used for JavaScript access, switch to `id` and use `document.getElementById()`, or use a `data-*` attribute for storing custom metadata.

## Invalid example

```html
<table name="prices">
  <tr>
    <td>Item</td>
    <td>Price</td>
  </tr>
</table>
```

## Valid example

Using `id` as a fragment target:

```html
<table id="prices">
  <tr>
    <td>Item</td>
    <td>Price</td>
  </tr>
</table>
```

If custom metadata is needed rather than a link target, a `data-*` attribute works:

```html
<table data-name="prices">
  <tr>
    <td>Item</td>
    <td>Price</td>
  </tr>
</table>
```
