Advertisement

Google Ad Slot: content-top

Table

~1 min read · HTML
On this page

In HTML, a table is used to organize and display data in a grid format of rows and columns. 

Explanation of Elements

  • <table>: The container for the entire table.
  • <tr>: Defines a table row.
  • <th>: Defines a header cell, which is typically bold and centered.
  • <td>: Defines a standard data cell.


Basic Structure of an HTML Table
Header 1 Header 2 Header 3
Row 1, Cell 1 Row 1, Cell 2 Row 1, Cell 3
Row 2, Cell 1 Row 2, Cell 2 Row 2, Cell 3
Try it yourself

Additional Table Elements

  • <caption>: Adds a title to the table.
  • <colspan>: Allows a cell to span multiple columns.
  • <rowspan>: Allows a cell to span multiple rows.
Example with colspan and rowspan
Name Details
John Age: 22 City: Boston
Jane City: Seattle
Try it yourself

Styling Tables

Tables can be styled with CSS to improve their appearance.

Example
Header 1 Header 2 Header 3
Row 1, Cell 1 Row 1, Cell 2 Row 1, Cell 3
Row 2, Cell 1 Row 2, Cell 2 Row 2, Cell 3
Try it yourself