Web Development · Module 2 · Lesson 31 min read

Lists & Tables

Lists

TagTypeUse
<ul>unordered (bullets)features, menus
<ol>ordered (numbers)steps, rankings
<li>list iteminside ul/ol
<dl>, <dt>, <dd>description listglossaries, FAQs

Navigation menus are usually a <ul> inside <nav>, styled with CSS.

Tables: for tabular data only

HTML
<table>
  <caption>Monthly sales</caption>
  <thead>
    <tr><th>Month</th><th>Sales</th></tr>
  </thead>
  <tbody>
    <tr><td>January</td><td>120</td></tr>
  </tbody>
</table>
  • <tr> row, <th> header cell, <td> data cell.
  • <thead>, <tbody> and <tfoot> group rows for meaning and styling.
  • <caption> describes the table for screen readers.
  • colspan="2" / rowspan="2" merge cells.

⚠️ Never use tables for page layout; use CSS Flexbox or Grid instead.

💡 On phones, wrap wide tables in a container with overflow-x: auto so they scroll sideways.

Example

HTML
<h2>Shopping list</h2>
<ul>
  <li>Milk</li>
  <li>Bread</li>
</ul>

<h2>How to make tea</h2>
<ol>
  <li>Boil water</li>
  <li>Add tea leaves</li>
  <li>Wait 3 minutes</li>
</ol>

<table border="1" cellpadding="6">
  <caption>Exam results</caption>
  <thead>
    <tr><th>Student</th><th>Score</th></tr>
  </thead>
  <tbody>
    <tr><td>Ana</td><td>92</td></tr>
    <tr><td>Ben</td><td>78</td></tr>
  </tbody>
</table>