Paste a Spreadsheet, Get a Table a Screen Reader Can Follow
A screen reader takes a table one cell at a time. Without a caption and marked-up headers, its user hears figures with nothing to say what they are.
A sighted reader takes in a table at a glance. The heading at the top of a column says what the figures underneath it mean. Someone using a screen reader moves through the table one cell at a time and hears only what the markup tells them. If the markup doesn’t say which heading belongs to which cell, they hear “£14” with no way of knowing whether it is a price, a saving or a total.
What the markup has to carry
The W3C’s tables tutorial sets out what a data table needs (W3C WAI). Header cells are marked as headers, with scope saying whether each heads a column or a row. A caption names the table, so a screen reader can announce “table, plans compared” rather than “table”.
This is what WCAG success criterion 1.3.1 asks for: structure that is shown visually has to be there in the code as well (Understanding 1.3.1). UK public sector websites are expected to meet WCAG 2.2 (GOV.UK), and plenty of charities and businesses hold themselves to the same standard.
What a markdown table gives you
Hugo turns a markdown table into a bare <table>. There is no caption, because markdown has nowhere to put one. There is no scope on the header cells. Nothing can mark the first column as headings. And there is no wrapper, so a wide table drags the whole page sideways on a phone.
What our editor tool adds
For Hugo sites edited through Sveltia CMS, our free extension adds a Table option to the editor (content tools guide). Select the cells in Word or Excel, copy them, paste them in, and fill in the caption. Two switches follow: whether the first row is a header, and whether the first column is. The second one is what makes a comparison table work, because each row’s name then belongs to the cells beside it.
The template that comes with it applies to every table on your site, old hand-written ones included. Column headers get scope="col". A wide table scrolls inside its own region, which a keyboard user can reach with the Tab key and which takes its name from the caption. A hand-written table gets the wrapper and the column headers as soon as you add the file; wrap it in the shortcode to give it a caption and row headers as well.
Two things it can’t do
Merged cells don’t survive, because markdown has no way for a cell to span two columns. The preview tells you when it spots one and pads the short rows so you can put them right. A line break inside a cell becomes a space, because the only way to write one in a markdown table is HTML that Hugo removes.
Getting it
It is free on any plan. You need three files in your repository and one line in your admin page, all in the content tools guide. We introduced the widget in September, in Paste a Table Straight Into Your Page, which covers the other job it does: fixing a table that had turned into lines of text.
Start with the table that carries your prices. It is the one a visitor most needs to read correctly.
Ready to Deploy?
Join Jamstack developers across the UK hosting their static sites with privacy and performance built in. Hosting is free for good, no credit card needed, with Plus features when you want them.
