Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Tables HTML Tables

Where do I put the tbody tag?

Objective asking me to add a tbody tag. The video covers thead and tfoot but not tbody.

index.html
<!DOCTYPE html>
<html>
  <head>
    <title>HTML Tables Challenge</title>
  </head>
  <body>
    <h1>HTML Tables Challenge</h1>

    <table>
      <thead>
        <tbody>
        <tr>
          <th>Fruits</th>
          <th>Veggies</th>

        </tr>
      </tbody>
      </thead>
    </table>


  </body>
</html>

2 Answers

The table body tag is used to designate the section of a table that contains all of the data cells, i.e. one or more <tr> tags can be contained in the <tbody> </tbody>tags.

If the <thead> tag is used then it comes first, followed by the <tfoot> tag, and finally one or more <tbody> tags.

Jeff Lemay
Jeff Lemay
14,268 Points

For tables, everything goes in the < table > element.

Inside the < table >, there are 3 main section: header, body, footer.

Inside each of those main sections, you can have rows and cells (and even other whole tables).

<table>
    <thead>
        <!-- table header -->
    </thead>

    <tbody>
        <!-- table body-->
    </tbody>

    <tfooot>
        <!-- table footer-->
    </tfoot>
</table>