4 ms·
https://www.w3.org/TR/html-polyglot/ https://www.w3.org/TR/html-polyglot/ is good reading on this topic too. A fun thing that I learned recently is that `table
by chrismorgan 5y ago
https://www.w3.org/TR/html-polyglot/ https://www.w3.org/TR/html-polyglot/ is good reading on this topic too.
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.
- TacticalCoder 5y ago> tbody is genuinely optional in the spec IIRC optional in the HTML spec only. Not in the XHMTL one and not in the polyglot syntax.
- chrismorgan 5y agoThe XHTML spec is obsolete and irrelevant. It’s replaced by the HTML spec using XML syntax. (W3C classes it as a Superseded Recommendation.) But tbody was optional even in XHTML 1.0 Strict; quoting https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd 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.
- aidos 5y agoBack in the days when we used to nest tables 70 deep for layouts I don’t recall anyone using tbody - was it added later?
- merb 5y agotbody is old, but was not widely used before html5 or modern spa's that required them.
- chrismorgan 5y agothead/tfoot/tbody were introduced in HTML 4, with tbody mandatory (that is, `table > tr` was now invalid), but implied (that is, its start and end tags were both optional, so that <table><tr>…</tr></table> would be parsed the same as <table><tbody><tr>…</tr></tbody></table>). Source: https://www.w3.org/TR/html4/struct/tables.html#h-11.2 https://www.w3.org/TR/html4/struct/tables.html#h-11.2: <!ELEMENT TABLE - - (CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+)> <!ELEMENT TBODY O O (TR)+ -- table body -->