Jens Oliver Meiert

HTML Concepts: Indicators for Layout Tables

Post from September 13, 2021, filed under .

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.

Tweet this? (If it changed your life, you delight me with a coffee.)

About Me

Jens Oliver Meiert, on April 29, 2020.

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

If you have questions or suggestions about what I write, please leave a comment (if available) or a message.

Read More

Have a look at the most popular posts, possibly including:

Cover: The Web Development Glossary.

Perhaps my most comprehensive book: The Web Development Glossary (2020). With explanations and definitions for literally thousands of terms from Web Development and related fields, building on Wikipedia as well as the MDN Web Docs. Available at Apple Books, Kobo, Google Play Books, and Leanpub.

Stay up-to-date? Follow me by feed or on Twitter.

Looking for a way to comment? Comments have been disabled, unfortunately.

Found a mistake? Email me, jens@meiert.com.

You are here: HomeArchive2021 → HTML Concepts: Indicators for Layout Tables

Last update: September 13, 2021

Professional frontend developers produce valid HTML and CSS.