Published by Patrick Mutisya · 8 days ago
By the end of this lesson you will be able to:
rowspan and colspan.width and height attributes.border, bgcolor, align, and valign to tables and cells.| Attribute | Purpose | Typical \cdot alues |
|---|---|---|
border | Defines the thickness of the outer border (in pixels). | 0, 1, 2, … |
cellspacing | Space between individual cells. | 0, 2, 5, … (pixels) |
cellpadding | Space between cell content and its border. | 0, 2, 5, … (pixels) |
width | Overall table width. | Pixel value (e.g., 600) or percentage (e.g., 80%) |
height | Overall table height. | Pixel value (e.g., 400) or percentage (e.g., 50%) |
colspan | Number of columns a cell should span. | Integer ≥ 1 |
rowspan | Number of rows a cell should span. | Integer ≥ 1 |
bgcolor | Background colour of a table or cell. | Colour name (e.g., lightgrey) or hex code (e.g., #e0e0e0) |
align | Horizontal alignment of the table on the page. | left, center, right |
valign | Vertical alignment of content inside a cell. | top, middle, bottom |
colspan and rowspanThe following table demonstrates how to create a weekly class timetable where some lessons occupy more than one period or day.
| Time | Monday | Tuesday | Wednesday | Thursday | Friday |
|---|---|---|---|---|---|
| 08:00‑09:00 | Mathematics | English | History | Geography | |
| 09:00‑10:00 | Science | Art | Physical Education | Music | Computer Science |
| 10:00‑11:00 | Biology | Chemistry | French | Spanish | |
| 11:00‑12:00 | Lunch Break | Drama | Economics | ||
Choosing between pixel and percentage values depends on the intended display environment:
<table width="800" height="400"> ensures the table is 800 px wide regardless of screen size.<table width="90%" height="auto"> lets the table expand to 90 % of its container’s width.While modern web design prefers CSS, the IGCSE syllabus still expects knowledge of legacy presentational attributes. Below is a concise checklist for quick reference:
border="2" – 2‑pixel border around the table.cellspacing="4" – 4 px gap between cells.cellpadding="6" – 6 px padding inside each cell.bgcolor="#eeeeee" – Light grey background for the whole table.align="center" – Centers the table horizontally on the page.bgcolor, align, valign, width, height.colspan or rowspan cell can shift subsequent columns, breaking the layout.Create a table that meets the following specifications:
#cce5ff and a 2‑pixel border.rowspan).