HTML Table

By onjsdev

The table element is a fundamental part of HTML that enables the creation of tabular data. Tables allow website developers to organize and present data in an easy-to-read format, making it easier for users to understand and analyze the information.

In this article, we'll explore the table element and its child elements to create rows and data cells. Let's get started.

Table Element In HTML

HTML provides us the table tag so that we can easily add a table content our website. The table element also contains other elements such as the thead (table head), tbody (table body), and td (table data) etc. elements.

Let's discover them in order.


The thead (table head) element is used to group the header content in a table. The header content of a table typically includes column titles, descriptions, or any other metadata


In HTML, the tbody tag is used to group the body content of an HTML table. The body content typically contains the data that is displayed in the table, such as text, numbers, images, and links.


The tfoot element is used to group the footer content of an HTML table. The footer content typically contains summary information about the data in the table, such as totals, averages, or other calculations.


The td element is used to define a standard data cell within a table. It is an essential component of a well-structured HTML table and is used to display data within a specific row and column.


The th element is used to define a header cell within a table. It is similar to the td element, but it is typically used for the first row or column of a table, where the cell's content is a header or label for the data below or to the right.


The tr element is used to define a row within a table. It stands for "table row" and is used to group together multiple td or th elements to form a single row of data

Example Of Table Element In HTML

After tihs brief description for each table element, let's create a table consisting these element so that you can easily create own table in your website.

  <!-- Thead element contains the header row of the table -->
      <!-- Th elements represent the headers for each column of the table -->
  <!-- Tbody element contains the data rows of the table -->
      <!-- Td elements contain the data for each cell in a row -->
      <td>John Doe</td>
      <td>United States</td>
      <td>Jane Smith</td>
      <td>Ali Khan</td>
  <!-- Tfoot element contains the footer row of the table -->
      <!-- An empty td element is used to align the "Total" cell with the other cells in the row -->

And here is the result after adding the following style it.

  table {
    font-family: Arial, sans-serif;
    border-collapse: collapse;
    width: 100%;
  td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
  th {
    background-color: #f2f2f2;
    color: #333;
  tr:nth-child(even) {
    background-color: #f2f2f2;
  tfoot {
    font-weight: bold;

table element in html


In this article, we have explored the various table elements available in HTML and their specific purposes.

To demonstrate how these elements work together, we created a simple HTML table that included all the different table elements. We then used inline styles to format the table with borders, font size, and alignment.

Thank you for reading.