Jens Oliver Meiert

HTML Concepts: Indicators for Layout Tables

Published on Sep 13, 2021, filed under , (feed). (Share this on Mastodon or Bluesky?)

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 presentationProbably 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 elementsProbably a non-layout table
headers and scope attributesProbably a non-layout table
border attribute (non-conforming) with a value other than 0Probably a non-layout table
Visible borders set using CSSProbably a non-layout table
summary attributeUnclear, 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.

About Me

Jens Oliver Meiert, on November 9, 2024.

I’m Jens (long: Jens Oliver Meiert), and I’m a web developer, manager, and author. I’ve been working as a technical lead and engineering manager for companies you’ve never heard of and companies you use every day, I’m an occasional contributor to web standards (like HTML, CSS, WCAG), and I write and review books for O’Reilly and Frontend Dogma.

I love trying things, not only in web development and engineering management, but also in other areas like philosophy. Here on meiert.com I share some of my experiences and views. (I value you being critical, interpreting charitably, and giving feedback.)