# Failure of Success Criterion 1.3.1 for incorrectly associating table headers and content via the headers and id attributes

ID: F90

Technology: failures

Type: Failure

## When to Use

HTML

## Description

One way for authors to explicitly associate header cells to data cells is by using the id and headers attributes. These allow the author to associate multiple header cells to a particular data cell, which can be necessary when complex data tables with more than one level of heading are used.

The failure occurs when the relationship between data cells and corresponding header cells cannot be programmatically determined correctly because the association of `id` and `headers` attributes is faulty. This can happen, for example, when copying code within tables and forgetting to update the code.

## Examples

Note: The example below is based on the complex data table presented as example 1 of Technique H43: Using id and headers attributes to associate data cells with header cells in data tables.

### Table content not correctly associated to nested headers

In this example, nested headers are used, but the content cells are incorrectly associated via the `id` and `headers` attributes. All cells reference top level header 'Exams' (`id="e"`) - this isn't correct for the last three columns which should reference header 'Projects'. Also, the referencing of the second level column headers has been accidentally swapped even though in this example this makes no difference as the contents (1, 2, Final) are repeated.

Example Code:

    <table>
      <tr>
        <th rowspan="2" id="h">Homework</th>
        <th colspan="3" id="e">Exams</th>
        <th colspan="3" id="p">Projects</th>
      </tr>
      <tr>
        <th id="e1" headers="e">1</th>
        <th id="e2" headers="e">2</th>
        <th id="ef" headers="e">Final</th>
        <th id="p1" headers="p">1</th>
        <th id="p2" headers="p">2</th>
        <th id="pf" headers="p">Final</th>
      </tr>
      <tr>
        <td headers="h">15%</td>
        <td headers="e p1">15%</td>  <!-- should be "e e1" -->
        <td headers="e p2">15%</td>  <!-- should be "e e2" -->
        <td headers="e pf">20%</td>  <!-- should be "e ef" -->
        <td headers="e e1">10%</td>  <!-- should be "p p1" -->
        <td headers="e e2">10%</td>  <!-- should be "p p2" -->
        <td headers="e ef">15%</td>  <!-- should be "p pf" -->
      </tr>
    </table>

Failure example of table incorrectly associating headers attributes in table content (td) to table headers (th).

## Tests

### Procedure

1. For tables that associate data cells to header cells via the id and headers attributes, check that the programmatic association is correct.

### Expected Results

- If check #1 is false, then this failure condition applies and the content fails the Success Criterion.

## Related Techniques

- G115
- H43
- F46