4 ms·
I don't think tbody is really obscure to anyone writing with DOM. You can't embed a tr into a table: it has to be in a thead/tbody/tfoot. If you're writing HTML
by parminya 4y ago
I don't think tbody is really obscure to anyone writing with DOM. You can't embed a tr into a table: it has to be in a thead/tbody/tfoot. If you're writing HTML it's fine, the browser does it for you. But if you're writing DOM (directly or indirectly with e.g. React) you need to use the tbody tag or else it won't do you what you wanted.
- chrismorgan 4y agoFun fact: `table > tr` is actually valid HTML. > […] followed by either zero or more tbody elements or one or more tr elements […] — https://html.spec.whatwg.org/multipage/tables.html#the-table-element https://html.spec.whatwg.org/multipage/tables.html#the-table..., the table element, content model. Sure, the HTML syntax will imply it (and https://html.spec.whatwg.org/multipage/syntax.html#element-restrictions https://html.spec.whatwg.org/multipage/syntax.html#element-r... mentions this, how in HTML syntax `table > tr` is invalid), but this means that in XML syntax <table><tr><td/></tr></table> is actually valid. I believe XHTML compatibility is the reason for this. But I have no real idea quite why XHTML 1.0 decided to allow (tbody+|tr+) (basically a mixture of HTML 3.2 and HTML 4) rather than tbody+ like HTML 4.