3

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?

1
  • In programming just about every "bad" practice has a circumstance somewhere where it's the right thing to do Jun 9 '17 at 3:25
9

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.