by chrismorgan · 4y ago · 0 comments
A fun thing that I learned recently is that `table > tr` is actually valid, the tbody is genuinely optional in the spec, even though the HTML syntax injects it.
<!ELEMENT TABLE - -
(CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+)>
<!ELEMENT TBODY O O (TR)+ -- table body -->IIRC optional in the HTML spec only. Not in the XHMTL one and not in the polyglot syntax.
But tbody was optional even in XHTML 1.0 Strict; quoting https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd,
<!ELEMENT table
(caption?, (col*|colgroup*), thead?, tfoot?, (tbody+|tr+))>
I’m pretty sure that this will be the reason it’s optional in the HTML spec, since there’d be no point in it being optional otherwise, since it’s not attainable in the HTML syntax.