HTML Table


An HTML table provides a structured and organized way to present data in a tabular format on a webpage, similar to spreadsheets or grids. It consists of rows and columns, with each intersection forming a cell where content can be placed, such as text, numbers, or even images. 

<table> 
 <thead>
    <tr>
      <th>Header 1</th>
      <th>Header 2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Row 1, Cell 1</td>
      <td>Row 1, Cell 2</td>
    </tr>
    <tr>
      <td>Row 2, Cell 1</td>
      <td>Row 2, Cell 2</td>
    </tr>
  </tbody>
</table>

Output

Header 1Header 2
Row 1, Cell 1Row 1, Cell 2
Row 2, Cell 1Row 2, Cell 2


Explanation:

  • <table>: Defines the start of the table.
  • <thead>: Groups the header rows.
  • <tr>: Defines a row within the table.
  • <th>: Defines a header cell within a row.
  • <tbody>: Groups the main content rows.
  • <td>: Defines a standard cell within a row.

This structure uses <thead> for headers and <tbody> for the main content, though both are optional depending on your table’s complexity and semantics. Tables in HTML allow for organizing data into rows and columns, providing a structured way to present information on web pages.

Scroll to Top