Skip to content
techsnow

HTML Tables

Table Basics

Tables show data in rows and columns, like a spreadsheet: timetables, price lists, results.

TagMeaning
<table>Wraps the whole table
<tr>Table row
<th>Table header cell (bold and centred by default)
<td>Table data cell

Syntax:

<table>
  <tr>
    <th>Name</th>
    <th>Course</th>
    <th>Marks</th>
  </tr>
  <tr>
    <td>Ali</td>
    <td>Python</td>
    <td>85</td>
  </tr>
  <tr>
    <td>Sara</td>
    <td>HTML</td>
    <td>92</td>
  </tr>
</table>

Adding borders with CSS

table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid #ccc; padding: 10px; text-align: left; }
th { background: #f0f4f8; }