Both IE9 and Chrome14 log TBODY as the tagName of the element inside the <table>
The HTML5 spec on <table> clearly states :
followed by either zero or more tbody elements or one or more tr elements
Furthermore. The HTML5 spec on <tr> clearly states :
As a child of a table element, after any caption, colgroup, and thead elements, but only if there are no tbody elements that are children of the table element.
Why are browsers corrupting my DOM and injecting a <tbody> when
- I did not ask for one
- It’s perfectly valid without one
The answer of “backwards compatiblity” makes absolutely zero sense because I specifically opted in for a HTML5 doctype.
However, browsers don’t differentiate between versions of HTML. HTML documents with HTML5 doctype and with HTML4 doctype (with the small exception of HTML4 transitional doctype without URL in FPI) are parsed and rendered the same way.
I’ll quote the relevant part of HTML5 parser description: