Topics Map > Desktop

Accessible HTML Tables

How to create / edit html tables that are digitally accessible

HTML Table Best Practices:

  • Ideally, tables should not be used as a means for laying out web page content, but rather for the organization & display of true data
  • Avoid using nested tables (a table within a table)
  • Avoid tables with cells that span multiple columns or rows
  • Include a table caption to provide a brief summary of the table's content
  • Use column and row headers

The following example table includes elements that make it easier for visually impaired users relying on a screen reader to understand the table's content.  

Courses that UW-Madison students must take
to be admitted into the UW-Madison PharmD Program
Prerequisite Requirement Approved Courses
Calculus 1 course MATH 221
MATH 211
MATH 171 & 217
General Chemistry I 1 course and lab CHEM 103
CHEM 109 **
General Chemistry II 1 course and lab CHEM 104
CHEM 109 **
Organic Chemistry I 1 course and lab CHEM 343
Organic Chemistry II 1 course and lab CHEM 344 & CHEM 345
General Biology I 1 course and lab BIO/ZOOLOGY 101 & 102
BIO/ZOOLOGY/BOTANY 151
General Biology II
or Advanced Biology *
1 course BIO/BOTANY 130 ***
BIO/ZOOLOGY/BOTANY 152
Microbiology 1 course MICROBIO 101
MICROBIO 303

Here's the HTML code for the table:

<table class="transfer-equiv">
<tbody>
<tr>
<th class="col" scope="column" width="38%"><strong>Prerequisite</strong></th>
<th class="col" scope="column" width="26%"><strong>Requirement</strong></th>
<th class="col" scope="column" width="36%"><strong>Approved </strong>Courses</th>
</tr>
<tr>
<th class="row" scope="row"><strong>Calculus</strong></th>
<td>1 course</td>
<td>MATH 221<br>
MATH 211<br>
MATH 171 &amp; 217</td>
</tr>
<tr>
<th class="row" scope="row"><strong>General Chemistry I</strong></th>
<td>1 course and lab</td>
<td>CHEM 103<br>
CHEM 109&nbsp;<strong>**</strong></td>
</tr>
<tr>
<th class="row" scope="row"><strong>General Chemistry II</strong></th>
<td>1 course and lab</td>
<td>CHEM 104<br>
CHEM 109&nbsp;<strong>**</strong></td>
</tr>
<tr>
<th class="row" scope="row"><strong>Organic Chemistry I</strong></th>
<td>1 course and lab</td>
<td>CHEM 343</td>
</tr>
<tr>
<th class="row" scope="row"><strong>Organic Chemistry II</strong></th>
<td>1 course and lab</td>
<td>CHEM 344 &amp; CHEM 345</td>
</tr>
<tr>
<th class="row" scope="row"><strong>General Biology I</strong></th>
<td>1 course and lab</td>
<td>BIO/ZOOLOGY 101 &amp; 102<br>
BIO/ZOOLOGY/BOTANY 151</td>
</tr>
<tr>
<th class="row" scope="row"><strong>General Biology II<br>
or Advanced Biology *<br>
</strong></th>
<td>1 course</td>
<td>BIO/BOTANY 130 <strong>***</strong><br>
BIO/ZOOLOGY/BOTANY 152</td>
</tr>
<tr>
<th class="row" scope="row"><strong>Microbiology</strong></th>
<td>1 course</td>
<td>MICROBIO 101<br>
MICROBIO 303</td>
</tbody>
</table>

Include a Table Caption

You can add a caption with a brief description of the table's contents - this is especially helpful if the table is complicated.  The example table above includes the following caption:

<table>
  <caption>
    Courses that UW-Madison students must take to be admitted into the UW-Madison PharmD Program
  </caption>
  <!-- … -->
</table>

Use Column and Row headers

Including column and row headers helps viewers understand exactly which headers / categories the data in a specific cell corresponds to.

  1. In the example table above, each of the 3 headings in the top row should indicate that they are headings that apply to the data in the columns that sit below them.
    Simply add the code scope="col" or scope="column" into the <th> tag:
        <tr style="background-color: #c5050c; color: white;">
          <th class="col" scope="column" width="38%"><strong>Prerequisite</strong></th>
          <th class="col" scope="column" width="26%"><strong>Requirement</strong></th>
          <th class="col" scope="column" width="36%"><strong>Approved </strong>Courses</th>
        </tr>
  2. Similarly, the first cell in each row should be designated as a header.  In the table above, the second row should have "Calculus" set as the row header - simply add the code scope="row":

        <tr>
          <th class="row" scope="row" style="text-align: left;"><strong>Calculus</strong></th>
          <td>1 course</td>
          <td>MATH 221<br>MATH 211<br>MATH 171 &amp; 217</td>
        </tr>

Complex Tables: Multi-Level Headers

In cases where you have a table that absolutely requires multi-level header cells, you can assign each header cell a unique id, and then link the relevant data cells with affiliated headers. 

In the example table below, each data cell has 3 headers affiliated with it.  For example, the cell that lists the Rural Pharmacy Practice course (in yellow), we can see that it's affiliated with (1) Course Title; (2) that it's a Pharmacy course with the course number prefix of 726; and (3) the course number is 630.

School of Pharmacy course details, including course title, number, edits, requisites, size, and semester offered.
Course Number Course Title Credits Requisite Semester Offered Class Size
Pharmacy (726)
630 Rural Pharmacy Practice 2 DPH-3 students in Rural Health program Fall Small seminar
674 Cannabinoids in Science and Society 2 DPH-2 Fall Small seminar
670 Veterinary Therapeutics 1 DPH-2 or DPH-3 Fall & Spring 30-45
Pharmacy Practice (728)
550 Fluids & Electrolytes 2 DPH-3 Fall Unlimited

To connect the Rural Pharmacy Practice data cell with its 3 related headers, you'll need to do the following to each column header:
(1) assign a unique id to each <th> and (2) set the scope to column.  

  <table class="stripe" style="width: 90%; height: 297.733px;" cellspacing="0" cellpadding="5">
    <tbody>
      <tr class="black" style="height: 47.3667px;">
        <th width="9%" scope="col" id="cnumber">Course Number</th>
        <th width="40%" scope="col" id="ctitle">Course Title</th>
        <th width="8%" scope="col" id="credits">Credits</th>
        <th width="27%" scope="col" id="reqs">Requisite</th>
        <th width="8%" scope="col" id="sem">Semester Offered</th>
        <th width="7%" scope="col" id="csize">Class Size</th>
      </tr>

In the header row for Pharmacy (726) courses that spans 6 columns, you'll need to:
(1) assign a unique id and(2) set the scope to colgroup.

<tr class="dark-gray" style="height: 29px;">
        <td colspan="6" id="pharmacy" scope="colgroup"><strong>Pharmacy (726)</strong></td>
</tr>
   

And finally, in the data cell that lists the Rural Pharmacy Practice course, you'll need to list the 3 affiliated header id's. 
In this case, you'd use headers="pharmacy p630 ctitle"

  <tr style="height: 29px;">
        <th headers="pharmacy" id="p630" style="text-align: right;" >630</th>
        <td headers="pharmacy p630 ctitle"><a href="#rural-health">Rural Pharmacy Practice</a></td>
        <td headers="pharmacy p630 credits" style="text-align: center;" >2</td>
      <td headers="pharmacy p630 reqs">DPH-3 students in Rural Health program</td>
        <td headers="pharmacy p630 sem">Fall</td>
        <td headers="pharmacy p630 csize">Small seminar</td>
</tr>

For more detailed info and examples of complex tables, visit the Web Accessibility Initiative website:



Keywords:
accessible table, html table 
Doc ID:
158250
Owned by:
Sally G. in School of Pharmacy
Created:
2026-02-02
Updated:
2026-02-02
Sites:
School of Pharmacy