CHAPTER 04
Beginner
HTML Lists and Tables
Updated: May 10, 2026
20 min read
1. Introduction
Welcome to Chapter 4! Content on the web isn't always just paragraphs. Often, we need to present organized lists of items or multi-dimensional data grids. In this chapter, you will master HTML Lists and Tables.2. Learning Objectives
By the end of this chapter, you will be able to:- Create unordered (bulleted) and ordered (numbered) lists.
- Nest lists within other lists.
- Build structured HTML tables with rows, columns, and headers.
-
Merge table cells using
colspanandrowspan.
3. Unordered Lists
An unordered list is used when the sequence of items does not matter (like a grocery list). It uses bullet points.-
<ul>: Defines the Unordered List.
-
<li>: Defines a List Item inside the list.
html
4. Ordered Lists
An ordered list is used when the sequence matters (like step-by-step instructions). It automatically numbers the items.-
<ol>: Defines the Ordered List.
html
5. Description Lists
Description lists are used for dictionaries or key-value pairs.-
<dl>: Description List.
-
<dt>: Description Term (the key).
-
<dd>: Description Details (the value).
html
6. Nested Lists
You can put a list inside another list! This is perfect for complex menus or multi-level outlines.
html
7. HTML Tables Basics
Tables are used to display tabular data in rows and columns (like an Excel sheet).-
<table>: The container for the entire table.
-
<tr>: Table Row.
-
<th>: Table Header cell (bold and centered by default).
-
<td>: Table Data cell (regular text).
html
8. Semantic Table Sections
For better organization and styling, group table rows using<thead>, <tbody>, and <tfoot>.
html
9. Colspan and Rowspan
Sometimes a cell needs to span across multiple columns or multiple rows.-
colspan="2": Merges 2 columns horizontally.
-
rowspan="2": Merges 2 rows vertically.
html
10. Table Captions
You can add a title to a table using the<caption> tag. It must be the first child of the <table> element.
html
11. Best Practices & Common Mistakes
Best Practices:- Use Tables ONLY for tabular data (numbers, schedules, reports).
- NEVER use tables to design the layout of your webpage (use CSS Flexbox/Grid for that).
Common Mistakes:
-
Forgetting to wrap
<td>or<th>inside a<tr>.
-
Mismatched
colspancalculations, causing the table layout to visually break.
12. Mini Project: Student Report Card
Task: Build a tabular report card with merged headers.
html
13. MCQ Quiz
- 1. Which tag creates a numbered list?
-
A)
<ul>
-
B)
<ol>
-
C)
<li>
-
D)
<list>
-
2.
What does the
<tr>tag define in a table?
- A) Table Row
- B) Table Record
- C) Table Rule
- D) Table Header
- 3. Which attribute merges two columns into one?
-
A)
rowspan
-
B)
merge
-
C)
colspan
-
D)
span
14. Interview Questions
Q: When should you NOT use HTML tables? A: You should never use HTML tables for constructing webpage layouts. In the early 2000s, developers used tables to build sidebars and headers, but this is terrible for accessibility, responsiveness, and SEO. Tables are strictly for displaying 2D tabular data.Q: Explain the difference between <th> and <td>.
A: <th> is used for table header cells; it denotes what a column or row represents, and is rendered bold and centered by default. <td> is used for standard data cells.
15. Summary
You've mastered organizing data! You can now build clean, nested lists and create complex data tables featuring merged columns and semantic segments like<thead> and <tfoot>.