T E C h O C E A N H U B

Table headers and cells in HTML

In HTML, tables are created using the <table> element, and you can define table headers using the <th> (table header) element and table cells using the <td> (table data/cell) element. Here’s an example of how to structure a basic table with headers and cells:

<table>
  <tr> <!-- Table row -->
    <th>Header 1</th> <!-- Table header cell -->
    <th>Header 2</th>
    <th>Header 3</th>
  </tr>
  <tr>
    <td>Cell 1</td> <!-- Table data cell -->
    <td>Cell 2</td>
    <td>Cell 3</td>
  </tr>
  <tr>
    <td>Cell 4</td>
    <td>Cell 5</td>
    <td>Cell 6</td>
  </tr>
</table>

In this example, we have a table with three columns (Header 1, Header 2, Header 3) and two rows. The first row contains the table headers (<th>) and the subsequent rows contain the table cells (<td>).

You can add more rows by adding additional <tr> elements, and within each row, you can include more header cells (<th>) or data cells (<td>), as needed.

It’s worth mentioning that tables are typically used for tabular data, so make sure to use them appropriately according to the content you want to display.


Copyright ©TechOceanhub All Rights Reserved.