There are differences between HTML and XHTML.
HTML requires the tbody element. However, its start and end tags are optional. That means if you write
<table> <tr><td>data</td></tr> </table>
tr will always be inside tbody , regardless of whether you write tags explicitly or not. Same story for this table:
<table> <thead> <tr><th>header</th></tr> </thead> <tr><td>data</td></tr> </table>
Here the second tr will be wrapped in tbody .
In XHTML, the tbody element is only needed if you have thead and / or tfoot .
So, the first example above is valid XHTML. However, there is a difference with HTML: tr will be directly inside the table in the DOM tree. (You wonβt be able to see the difference, but you need to keep this in mind if you need to manipulate a table in JavaScript.)
The second example is incorrect XHTML, and you should not be surprised if it has different results in different browsers.
source share