Is the tbody command necessary in all tables?
Because I have not put the command in my table but it works fine. However it seems hat somehow that chrome put it in automatically.
If you do not need it then when do you use it?
答案 0 :(得分:3)
Short answer - no. As my Trusty source mentions,
The
<thead>
,<tbody>
, and<tfoot>
elements will not affect the layout of the table by default. [.. different article regarding these, under tables:..] These are not required or necessary, although they can come in handy [...]
It's not necessary, most of the times (except for some DOMs which will automatically add it). The <tbody>
element is used in conjunction with the <thead>
and <tfoot>
elements to specify each part of a table (body, header, footer) - if you want to apply different settings (i.e, css) for each of these.
Browsers can use these elements to enable scrolling of the table body independently of the header and footer. Also, when printing a large table that spans multiple pages, these elements can enable the table header and footer to be printed at the top and bottom of each page. That's pretty much it.