14

If there are multiple <tbody> tags in an HTML <table>, is this valid?

<table>
    <tbody>
    </tbody
    <tbody>
    </tbody
</table>
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

4 Answers4

22

Yes, the DTD shows that it is allowed.

<!ELEMENT table
     (caption?, (col*|colgroup*), thead?, tfoot?, (tbody+|tr+))>

The DTD also has a comment which explains why:

Use multiple tbody sections when rules are needed between groups of table rows.

dogbane
  • 266,786
  • 75
  • 396
  • 414
5

I copy pasted your title in google and the first link is : http://www.w3.org/TR/html401/struct/tables.html#h-11.2.3 ,

"Table rows may be grouped into a table head, table foot, and one or more table body sections",

so yes you can !

remi bourgarel
  • 9,231
  • 4
  • 40
  • 73
1

Multiple table bodies is perfectly acceptable.

sevenseacat
  • 24,699
  • 6
  • 63
  • 88
1

Yes, you can have multiple tbodys in the same table.

Example:

<table>
    <tbody>
        <tr><td>Monday</td><td>#1</td></tr>
        <tr><td>Friday</td><td>#2</td></tr>
    </tbody>
    <tbody>
        <tr><td>Monday</td><td>#3</td></tr>
        <tr><td>Friday</td><td>#4</td></tr>
    </tbody>
</table>
Floern
  • 33,559
  • 24
  • 104
  • 119