Is it necessary to have <tbody>
in every table? According to Standards.
views:
67answers:
3Only if you define thead
and tfoot
. It is mostly used when the table has multiple bodies of content. If the data in the table is easily understood to be the tbody
then you can safely omit it.
Most browsers are forgiving but even so I add the pair in all tables that I use now. Even trivial tables. Especially now that I'm using CSS more and more to decorate those tables.
All that being said I have old tables that still work fine on the newest browsers. I'm learning the hard way but taking the few extra Micro seconds to add the optional tags here and there ends up saving you money/time in the long run.
Dave
Quoting the HTML 4 spec: "The TBODY start tag is always required except when the table contains only one table body and no table head or foot sections. The TBODY end tag may always be safely omitted."
So, you must have a <tbody>
tag if you have a <thead>
or <tfoot>
However, w3schools says that "The tag is only partially supported in all major browsers," so it is not recommended to use this if you want your code to work correctly in all browsers.