HTML Questions & Answers Logo
HTML Questions & Answers Part of the Q&A Network
Q&A Logo

How can I create a table with a header, body, and footer section?

Asked on Sep 18, 2025

Answer

To create a table with distinct header, body, and footer sections, you can use the <thead>, <tbody>, and <tfoot> elements respectively. These elements help in organizing the table's structure semantically.
<!-- BEGIN COPY / PASTE -->
    <table>
      <thead>
        <tr>
          <th>Header 1</th>
          <th>Header 2</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>Data 1</td>
          <td>Data 2</td>
        </tr>
        <tr>
          <td>Data 3</td>
          <td>Data 4</td>
        </tr>
      </tbody>
      <tfoot>
        <tr>
          <td>Footer 1</td>
          <td>Footer 2</td>
        </tr>
      </tfoot>
    </table>
    <!-- END COPY / PASTE -->
Additional Comment:
  • The <thead> element is used to group header content in a table.
  • The <tbody> element contains the main data of the table.
  • The <tfoot> element is used for footer content, often for summaries or totals.
  • Using these elements improves accessibility and allows for easier styling.

✅ Answered with HTML best practices.


← Back to All Questions
The Q&A Network