Question

I found myself wanting to put a table in a table. I had a momentary war flashback of legacy webpages and email html templates and was about to shelve the idea, but then I considered that it kind of made sense in this case.

I have a table showing tabular game information. There are 2 players in a game. I want to show their tabular information in the game table.

Is this a good situation for using a table in a table? Is it semantic HTML? Are tables inside tables even valid in HTML5?

Was it helpful?

Solution

Semantic HTML is about accurately describing the semantic structure of your document. If your document contains tabular data, then use a table. If your document contains tabular data which is itself tabular, then use a table-in-a-table.

In fact, I would argue that not using a table to represent tabular data violates semantic HTML.

This isn't SQL, the First Normal Form (data must be atomic) doesn't apply. (Oh, and BTW, there are Relational Databases called (NF)² for Non-First-Normal-Form which allow exactly that: columns whose type is a table.)

The Content Model of a <td> element is Flow Content, which includes the <table> element.

Licensed under: CC-BY-SA with attribution
scroll top