How do you make an HTML data table accessible?

An accessible data table exposes the relationship between every data cell and the headers that describe it. Use a real <table>, mark headers with <th> and keep data in <td> elements. Visual alignment, bold text and background color do not provide those relationships to assistive technology.
Give the table a concise <caption> when users need a name for it. For a simple table, column headers in the first row may be clear from structure alone, but explicit scope="col" and scope="row" values make the intended direction easier to review. Do not leave empty header cells without checking how the first data column is identified.
<table>
<caption>Support hours</caption>
<tr><th scope="col">Day</th><th scope="col">Hours</th></tr>
<tr><th scope="row">Monday</th><td>09:00 to 17:00</td></tr>
</table>
Complex tables with grouped or multi-level headers may require colgroup, rowgroup, or explicit id and headers associations. Before adding complicated markup, consider splitting the data into smaller tables. Make responsive tables scroll or reformat without hiding cells, headers or keyboard focus. If columns can be sorted, the control needs an accessible name and the current sort direction must be exposed programmatically. Avoid placing unrelated interactive widgets inside cells when a simpler structure can present the same task.
Test by moving through cells with a screen reader and listening for the relevant row and column headers. Also check zoom, reflow and high-contrast presentation. A user should be able to identify what each value means without visually tracing its row and column back to the top or side.