WeLearn

Grade 11 Information Technology · Lesson 4.5

HTML Tables

Unit 4: Web Development

HTML tables display data in rows and columns, such as timetables, mark lists or price lists. A table is created with the <table> element. Inside it, each row is defined with <tr> (table row). Each row contains cells: <td> (table data) for ordinary cells and <th> (table header) for heading cells, which browsers show bold and centred by default. The number of cells in each row should normally be the same.

Key terms

<table>
element that creates a table
<tr>
a table row
<td>
a data cell
<th>
a header cell
<caption>
title of a table
colspan
attribute that merges cells across columns
rowspan
attribute that merges cells down rows
All Grade 11 Information Technology key terms →

Summary

  • <table> contains rows <tr>, which contain cells <td> or <th>.
  • <caption> gives a title; <thead>, <tbody>, <tfoot> group rows.
  • colspan and rowspan merge cells.
  • Use tables for data, not page layout.

In everyday life: Online bus and flight timetables, exam result pages and price lists are typically shown as HTML tables.

Check yourself

  • What is the difference between <td> and <th>?
  • Which attribute merges cells across columns?
  • Where does <caption> go?
  • Why should tables not be used for page layout?

Practice questions

  1. 1. In an HTML table, which tag defines a single row?

    • A. <td>
    • B. <th>
    • C. <tr>
    • D. <table>
    Show answer

    Answer: <tr>

    <tr> is a table row; <td> cells and <th> header cells go inside it.

On WeLearn

The full lesson: reading notes, worked examples, class activities and the Unit 4 quiz

Study HTML Tables on WeLearn

Teach HTML Tables with WeLearn

We will bring a demo to your school: a lesson on your interactive TV, a virtual lab and a classroom game, with your own teachers.