Wide tables can overflow a phone screen because they contain too many columns to fit. A scrollable container can preserve the table's relationships without chopping data into confusing pieces. Before writing the code, picture the information as a small grid. Each label should help a reader understand the value next to it.
What You Need to Know
Give keyboard users a way to reach an overflow region when needed, and test focus and scrolling behavior. Do not hide essential columns just to fit a narrow layout.
Read a table like a story about data. The caption says what you are looking at; row and column headers explain what the numbers or words mean.
Example: See It in Action
This example keeps the idea small. Copy it carefully, then follow the explanation instead of guessing what the browser will do.
This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.
<div class="table-scroll" role="region" aria-label="Budget table" tabindex="0">
<table>
<caption>Club budget</caption>
<tr>
<th scope="col">Month</th>
<th scope="col">Income</th>
<th scope="col">Costs</th>
</tr>
<tr>
<th scope="row">January</th>
<td>$200</td>
<td>$120</td>
</tr>
</table>
</div>
Let’s Understand the Example
- Table represents information whose row and column relationships matter.
- Caption gives the whole data table a clear name.
- Class is a reusable label for styling or scripts; several elements may share the same class.
- Role describes an accessibility role when native HTML semantics do not already provide it.
- Aria-label supplies an accessible name when a visible label is unavailable or inadequate.
- Scope explains which table row, column or group a th cell labels.
Look at a data cell and ask: “What row and column does this value belong to?” The header elements help answer that question, including for people who navigate the table with a screen reader.
What Should You See?
You should see a grid for “Club budget”, with headers such as “Month”, “Income”, “Costs”. The browser displays cells, but meaningful table markup also helps readers connect each cell to its labels.
Read the first data row aloud together with its column labels. If you cannot explain a value without pointing to its position on screen, strengthen the headers.
Try It Yourself
- Resize the page to a narrow viewport and test horizontal scrolling with keyboard and touch.
- Save your changes, open or refresh the page, and compare the result with the original example.
- Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.
Common Beginner Mistakes
- Making a wide table unreadable by shrinking all text to tiny sizes.
- Do not replace actual header cells with bold ordinary cells. Header markup is part of the meaning, not just the appearance.
Key Takeaways
- Wide tables can overflow a phone screen because they contain too many columns to fit.
- Table represents information whose row and column relationships matter.
- Give keyboard users a way to reach an overflow region when needed, and test focus and scrolling behavior. Do not hide essential columns just to fit a narrow layout.