tags:

views:

50

answers:

6

kind of a silly question, but ive been seeing things such as tbody and thead/tfood tags in other peoples tables

are these required even if they're empty for good markup? or can i just leave them out?

thanks

+2  A: 

They aren't required, but they let you do some more advanced things with headers and footers: http://www.htmldog.com/guides/htmladvanced/tables/

slavalle
A: 

if you really need tables, you should use them. If you use tables only for design purposes you should switch to css-markup.

A simple correct table example:

<table>
  <thead>
    <tr>
      <td>id</td>
      <td>name</td>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td>User1</td>
    </tr>
    <tr>
      <td>2</td>
      <td>User2</td>
    </tr>
  </tbody>
</table>
Tobias P.
You should never use tables for design purposes :) That's what div- and p-tags were invented for.
faileN
well im trying to spread out my navigation links evenly(Gallery, Portfolio, Contact, etc)- i figured a table would be easiest way to get the aesthetics i wanted
Gazow
Tables are for showing data which HAVE a table form. Design purposes should NEVER NEVER NEVER be designed with tables, CSS can do all you want to and much more.
Tobias P.
@Gazow you should use an unordered list for navigation rather than a table, here's some basics on the code you would need for that purpose: http://www.alistapart.com/articles/taminglists/
slavalle
thanks i suppose thats what i want then :D
Gazow
A: 

Yes, that is proper markup. Though they are optional You can read further on the W3Schools page.

J Angwenyi
+2  A: 

Those tags are not required and a page would validate even without them.

kemp
+1  A: 

The table sections (thead/tbody/tfoot) are optional. The table caption (caption) and column definitons (col/colgroup) are also optional.

In HTML (but not XHTML) the closing tag for rows and cells are also optional, so you could write a table as:

<table>
  <tr>
    <th>1
    <th>2
  <tr>
    <td>3
    <td>4
  <tr>
    <td>5
    <td>6
</table>

It's however recommended that you close the tags to get better structure in the code. It also makes it a lot easier if you decide to change to XHTML.

Guffa
A: 

The <tbody> tag is only partially supported in all major browsers.
Tables may have multiple bodies, but when it only has one single body, the HTML tbody tag may be safely omitted.

Tommy