Key Ideas
1When to Use Tables. Tables are for tabular data — information that has a meaningful row/column relationship. They are not for page layout (that's what CSS Grid and Flexbox are for).
2Core Table Elements. A basic HTML table uses four elements: <table>, <tr>, <th>, and <td>. Think of it like a spreadsheet — rows contain cells.
3Your First Table
HTMLBasic table structureCopy
<table>
<caption>Web Programming Languages Comparison</caption>
<!-- Header row -->
<tr>
<th>Language</th>
<th>Type</th>
<th>Use Case</th>
</tr>
<!-- Data rows -->
<tr>
<td>HTML</td>
<td>Markup</td>
<td>Structure</td>
</tr>
<tr>
<td>CSS</td>
<td>Stylesheet</td>
<td>Styling</td>
</tr>
<tr>
<td>JavaScript</td>
<td>Scripting</td>
<td>Interactivity</td>
</tr>
</table>
Rendered with CSS, that code produces:
Web Programming Languages Comparison
LanguageTypeUse Case
HTMLMarkupStructure
CSSStylesheetStyling
JavaScriptScriptingInteractivity
Section 4
th vs td — Semantic Difference. Using <th> for header cells isn't just visual — it adds semantic meaning that screen readers use to associate headers with data cells. Screen readers say "Langua...
4Basic Table Styling. By default HTML tables have no borders or padding. Use CSS border-collapse: collapse to merge borders, and padding on cells for readable spacing.