<table>, <tr>, <th>, <td>.rowspan and colspan.width and height (pixels or percentages).border, bgcolor, align, valign) and understand their HTML5 deprecation and CSS equivalents.scope attribute on <th> for improved accessibility.<div> elements and use CSS classes for a clean separation of content and presentation.<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Weekly school timetable">
<title>Weekly Timetable</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Weekly Timetable</h1>
<!-- Table is placed inside a wrapper div for CSS styling -->
<div class="table-wrapper">
<!-- table goes here -->
</div>
</body>
</html>
| Attribute | Purpose (Why use it?) | Typical values | HTML5 status | CSS equivalent |
|---|---|---|---|---|
border | Draws a line around the table or cell. | 0, 1, 2, … (pixels) | Deprecated – presentational. | border: 2px solid #000; |
cellspacing | Space between adjacent cells. | 0, 2, 5, … (pixels) | Deprecated. | border-spacing: 4px; |
cellpadding | Space between cell content and its border. | 0, 2, 5, … (pixels) | Deprecated. | padding: 6px; on td, th |
width | Overall table width. | Pixel (e.g. 600) or % (e.g. 80%). | Allowed but discouraged. | width: 80%; |
height | Overall table height. | Pixel or %. | Allowed but discouraged. | height: auto; |
colspan | Make a cell span several columns. | Integer ≥ 1 | Valid. | Handled by the same attribute. |
rowspan | Make a cell span several rows. | Integer ≥ 1 | Valid. | Handled by the same attribute. |
bgcolor | Background colour of a table or cell. | Colour name or hex (e.g. #e0e0e0). | Deprecated. | background-color: #e0e0e0; |
align | Horizontal alignment of the table on the page. | left, center, right | Deprecated. | margin: 0 auto; (centre) or text-align for cell content. |
valign | Vertical alignment of content inside a cell. | top, middle, bottom | Deprecated. | vertical-align: middle; |
scope | Indicates whether a <th> is a column, row or group header – improves screen‑reader navigation. | col, row, colgroup, rowgroup | Valid (HTML5). | No CSS equivalent – semantic only. |
colspan and rowspanThese attributes let a single cell occupy the space of several columns or rows. They are essential for timetables, price lists, and any layout where an item spans multiple periods.
<table border="1" width="100%" cellpadding="5" cellspacing="0"><thead>
<tr bgcolor="#d9edf7">
<th scope="col">Time</th>
<th scope="col">Monday</th>
<th scope="col">Tuesday</th>
<th scope="col">Wednesday</th>
<th scope="col">Thursday</th>
<th scope="col">Friday</th>
</tr>
</thead>
<tbody>
<tr>
<td width="15%">08:00‑09:00</td>
<td bgcolor="#f2dede" colspan="2" align="center">Mathematics</td>
<td bgcolor="#dff0d8" align="center">English</td>
<td bgcolor="#fcf8e3" align="center">History</td>
<td bgcolor="#d9edf7" align="center">Geography</td>
</tr>
<tr>
<td>09:00‑10:00</td>
<td bgcolor="#dff0d8" align="center">Science</td>
<td bgcolor="#d9edf7" align="center">Art</td>
<td bgcolor="#f2dede" rowspan="2" align="center">Physical Education</td>
<td bgcolor="#fcf8e3" align="center">Music</td>
<td bgcolor="#dff0d8" align="center">Computer Science</td>
</tr>
<tr>
<td>10:00‑11:00</td>
<td bgcolor="#fcf8e3" align="center">Biology</td>
<td bgcolor="#d9edf7" align="center">Chemistry</td>
<!-- PE cell continues here because of rowspan="2" -->
<td bgcolor="#f2dede" align="center">French</td>
<td bgcolor="#dff0d8" align="center">Spanish</td>
</tr>
<tr>
<td>11:00‑12:00</td>
<td bgcolor="#d9edf7" colspan="3" align="center">Lunch Break</td>
<td bgcolor="#fcf8e3" align="center">Drama</td>
<td bgcolor="#f2dede" align="center">Economics</td>
</tr>
</tbody>
</table>
<table width="800" height="400">). Use when the audience is limited to a known device size (e.g. a school computer lab).<table width="90%">). Ideal for mixed‑device audiences because the table scales with its container.Justify your choice in the design rationale – the exam expects a short explanation.
/* styles.css */.table-wrapper {
overflow-x: auto; /* allows horizontal scroll on very small screens */
}
@media (max-width: 600px) {
table {
width: 100% !important; /* force full‑width on phones */
font-size: 0.9rem; /* slightly smaller text */
}
}
| HTML attribute (deprecated?) | CSS property | Example |
|---|---|---|
border="2" (deprecated) | border: 2px solid #000; | table { border: 2px solid #000; } |
cellspacing="4" (deprecated) | border-spacing: 4px; | table { border-spacing: 4px; } |
cellpadding="6" (deprecated) | padding: 6px; | td, th { padding: 6px; } |
bgcolor="#e0e0e0" (deprecated) | background-color: #e0e0e0; | td { background-color: #e0e0e0; } |
align="center" (deprecated) | margin: 0 auto; (table) or text-align: center; (cell) | table { margin: 0 auto; } |
valign="middle" (deprecated) | vertical-align: middle; | td, th { vertical-align: middle; } |
<th> for column/row headings and add scope="col" or scope="row" so screen‑readers can announce the correct context.title attribute on <table> provides a brief description for assistive tech.<div class="table-wrapper"> with overflow-x:auto prevents horizontal scrolling from breaking the page layout on small screens.<div> and using CSS classesSeparating structure (HTML) from presentation (CSS) makes maintenance easier and satisfies the “presentation layer” requirement of the syllabus.
<div class="timetable"><table class="styled">
… table rows …
</table>
</div>
Corresponding CSS (in styles.css)
.timetable { max-width: 100%; margin: 0 auto; }.styled { border-collapse: collapse; width: 100%; }
.styled th, .styled td { padding: 8px; border: 1px solid #ccc; }
colspan or rowspan cell. Result: later rows shift. Remedy: Count the total columns after each merged cell and verify it matches the header row.scope on <th>. Result: poorer accessibility. Remedy: Always add scope="col" for column headers and scope="row" for row headers.Below is a table that uses several deprecated attributes. Your tasks:
colspan, rowspan, scope).<table border="1" cellspacing="2" cellpadding="4" align="center"><tr bgcolor="#d9edf7">
<th>Item</th>
<th>Price</th>
</tr>
<tr valign="top">
<td>Notebook</td>
<td>$2.50</td>
</tr>
</table>
Build a table that meets all of the following specifications. Write the HTML code (you may add a linked CSS file) and include a short comment (≤ 30 words) explaining any audience‑related design decisions.
<th> with scope="col".rowspan.class="price-table" on the <table> and style it entirely with CSS (no presentational attributes).title="Product price list" attribute on the table for accessibility.<div class="table-wrapper"> to allow horizontal scrolling on very narrow screens.Example starter code (HTML only):
<div class="table-wrapper"><table class="price-table" title="Product price list">
<thead>
<tr>
<th scope="col">Product</th>
<th scope="col">Description</th>
<th scope="col">Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>Laptop</td>
<td rowspan="2">High‑performance notebook with 16 GB RAM</td>
<td>$999</td>
</tr>
<tr>
<td>Mouse</td>
<td>$25</td>
</tr>
<!-- more rows – add as needed -->
</tbody>
</table>
</div>
Now add the CSS (in styles.css) to achieve the required presentation.
<table>, <tr>, <th>, <td>.rowspan, colspan, width, height, border, cellspacing, cellpadding, bgcolor, align, valign, scope.scope on <th> for accessibility.<div> and use classes for clean styling.charset, viewport, description) in the <head> of any page you create.Your generous donation helps us continue providing free Cambridge IGCSE & A-Level resources, past papers, syllabus notes, revision questions, and high-quality online tutoring to students across Kenya.