0

http://jsbin.com/utisoz/edit#javascript,html

Ive created a simple table without Tbody

how ever it seems that it must generate Tbody.

enter image description here

why is that ?

does Table always generates Tbody ?

Royi Namir
  • 144,742
  • 138
  • 468
  • 792

3 Answers3

2

In HTML 4 a table is required to have a tbody child, but its start and end tags are optional.

<!ELEMENT TABLE - -
 (CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+)>


<!ELEMENT TBODY    O O (TR)+           -- table body -->

Some browsers do not respect this. So you may or may not get one depending on the browser.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • *Every* browser respects this. The requirement of adding `tbody` is also included in HTML5 parser. http://stackoverflow.com/questions/7490364/why-do-browsers-still-inject-tbody-in-html5 – duri Jan 16 '12 at 12:17
  • Yes, even old IE. The HTML4 specification is mostly based on how Internet Explorer behaved then. – duri Jan 16 '12 at 12:19
0

this is not the real HTML, the developer tool will add the tbody tag , but if you see the HTML source , you don't see the tbody tag

amd
  • 20,637
  • 6
  • 49
  • 67
0

I believe that for HTML4 valid markup a tbody will always be generated. It's not always true of invalid markup, and it's not necessarily true for HTML5 valid markup either. For instance, consider this markup which (with an appropriate DOCTYPE) is valid HTML5 but not valid HTML4.

<title>Test Case</title>
<table>
  <thead>
    <tr>
      <td></td>
    </tr>
  </thead>
</table>

This table will not have a tbody element.

Alohci
  • 78,296
  • 16
  • 112
  • 156