HTML Concepts: Indicators for Layout Tables

Post from September 13, 2021, filed under (feed).

You use tables for data, and therefore not for layout purposes (as was popular in the past). But how would you recognize a layout table? That’s what we’re looking at today in “HTML Concepts.”

While it may be easy for you and me to tell when a table is used inappropriately, it’s a different story for a user agent. The HTML specification covers this problem in its section on the table element.

First, the spec notes how in order to navigate a table, user agents “are encouraged to find heuristics to determine which tables actually contain data and which are merely being used for layout.”

Then it offers a few heuristics, but not without making clear that these are not precise, how they are merely “suggested as possible indicators.” Keep this in mind when looking at what are deemed technical indicators for layout tables:

Code Characteristic(s) Interpretation
role attribute with a value of presentation Probably a layout table
border attribute with a value of 0 (non-conforming) Probably a layout table
cellspacing and cellpadding attributes with a value of 0 (non-conforming) Probably a layout table
caption, thead, or th elements Probably a non-layout table
headers and scope attributes Probably a non-layout table
border attribute (non-conforming) with a value other than 0 Probably a non-layout table
Visible borders set using CSS Probably a non-layout table
summary attribute Unclear, as “both layout and non-layout tables have historically been given this attribute”

While we can tell by its contents whether a table is used for layout, these are ways to tell from the code. Fortunately, layout tables are largely a thing from the past, and for a modern web developer, knowledge of technical layout table indicators is of little practical value. But—now you know.

Toot or tweet about this?

About Me

Jens Oliver Meiert, on September 30, 2021.

I’m Jens, and I’m an engineering lead and author. I’ve worked as a technical lead for Google, I’m close to W3C and WHATWG, and I write and review books for O’Reilly. I love trying things, sometimes including philosophy, art, and adventure. Here on I share some of my views and experiences.

If you have a question or suggestion about what I write, please leave a comment (if available) or a message. Thank you!