DEV Community

Parthipan M
Parthipan M

Posted on

TABLE.HTML

Table tags in HTML

Table in HTML is a grid used to display data in rows and columns — like a spreadsheet.

How it works

  • <table> is the container for everything.
  • Inside it, each <tr> creates one row.
  • Inside each row,<td>creates a data cell, and <th>creates a header cell.

  • The browser lines up cells into columns automatically based on their position in each row.

HTML structure

  • <table>— wraps the whole table

  • <tr> — table row

  • <th>— header cell (bold, centered by default)

  • <td> — data cell

Grouping (optional but recommended)

  • <thead> — groups header row(s)

  • <tbody> — groups body rows

  • <tfoot> — groups footer row(s)

Other useful ones

  • <caption> — table title/description

  • <colgroup>/ <col> — apply styles to whole columns

Cell spanning

  • colspan="3" — cell spans n columns

  • rowspan="4" — cell spans n rows

Top comments (0)