Tables
Data ko rows aur columns mein rakho — clean aur clear.
Open Google Sheets. You see a grid — rows go left to right, columns go top to bottom. Each cell holds one piece of data. HTML tables work exactly the same way.
Tables are for displaying data that has a clear row-column relationship. Employee directories, pricing comparisons, schedules — anytime you have structured data, use a table. NOT for page layout.
There are 5 building blocks of tables:
- <table> — The spreadsheet itself.
- <tr> — One row.
- <th> — Header cell. Bold by default.
- <td> — Data cell.
- <caption> — Table title.
<table>
<thead>
<tr>
<th>Feature</th><th>HTML</th><th>CSS</th><th>JS</th>
</tr>
</thead>
<tbody>
<tr><td>Type</td><td>Markup</td><td>Style</td><td>Program</td></tr>
</tbody>
<tfoot>
<tr><td colspan="4">Learn all three</td></tr>
</tfoot>
</table>Just like spreadsheets have different features, HTML tables have different techniques.
CRITICAL RULE: Tables are for DATA, not LAYOUT. Use CSS Grid or Flexbox for layout.
Build a comparison table comparing 3 programming languages.
Open VS Code. Create file lang-compare.html
Use the starter code below:
<table>
<thead>
<tr><th>Feature</th><th>HTML</th><th>CSS</th><th>JS</th></tr>
</thead>
<tbody>
<!-- 4 data rows -->
</tbody>
<tfoot>
<!-- colspan footer -->
</tfoot>
</table>Complete these:
Done — Key Points:
- ✅
<table>wraps the entire table - ✅
<th>= header,<td>= data - ✅
colspanmerges columns,rowspanmerges rows - ✅ Tables for DATA only — CSS Grid for layout
Want to track your progress?
Log in to save your place and pick up where you left off.
Progress track karna chahte ho?
Login karo apni progress save karne ke liye aur jahan chhoda tha wahan se shuru karo.
Login