Skip to main content
HTML Validation

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

About This HTML Issue

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

No HTML specification has defined name on header cells, so it has no effect on how the table renders or how assistive technology reads it. The validator reports it twice: this warning, and an error saying that the attribute is not allowed on th at this point. Both go away once the attribute is removed.

What to use instead depends on what the name was meant to do. To identify a header cell, give it an id. An id works as a link target (page.html#year), and data cells can point to it through their headers attribute. To mark a header as labeling its column or row, add scope="col" or scope="row". To keep a value that only scripts read, move it to a data-* attribute such as data-name.

Scripts that look these cells up with document.getElementsByName() still find them while the attribute is there, so update them to getElementById() or a [data-name] selector when you change the markup.

Invalid example

<table>
  <tr>
    <th name="year">Year</th>
    <th name="revenue">Revenue</th>
  </tr>
  <tr>
    <td>2024</td>
    <td>1,200</td>
  </tr>
</table>

Valid example

Using id and scope on the header cells, with headers on the data cells:

<table>
  <tr>
    <th id="year" scope="col">Year</th>
    <th id="revenue" scope="col">Revenue</th>
  </tr>
  <tr>
    <td headers="year">2024</td>
    <td headers="revenue">1,200</td>
  </tr>
</table>

If the value is only metadata for scripts, a data-* attribute works:

<table>
  <tr>
    <th data-name="year">Year</th>
    <th data-name="revenue">Revenue</th>
  </tr>
  <tr>
    <td>2024</td>
    <td>1,200</td>
  </tr>
</table>

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?
🌍 Trusted by teams worldwide

Validate at scale.
Ship accessible websites, faster.

Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.

Scheduled Reports
API Access
Open Source Standards
€5 / week

1K Weekly

1,000 monthly checks. Cancel anytime.

Get 1K Weekly →

Join teams across 40+ countries