HTML Tables

HTML tables are used to display data in a structured grid format with rows and columns. A basic table consists of the following elements:

Basic Table Structure

<table border>
  <tr>
    <th>Name</th>
    <th>Age</th>
    <th>City</th>
  </tr>
  <tr>
    <td>John</td>
    <td>25</td>
    <td>New York</td>
  </tr>
  <tr>
    <td>Anna</td>
    <td>30</td>
    <td>London</td>
  </tr>
</table>

Live Example

Name Age City
John 25 New York
Anna 30 London

Common Table Tags

  • <table> – Starts the table
  • <tr> – Table row
  • <th> – Table header (bold and centered)
  • <td> – Table data cell
  • <caption> – Adds a title to the table

Tips

Tables should be used for tabular data. For layout purposes, modern websites use CSS Flexbox or Grid instead of tables.