<head> section of an IGCSE web page (title, charset, meta‑tags, external stylesheet links).<div> element for grouping content and applying classes/IDs..css) that defines background, font and table properties.class="…" or id="…".<div> containers.| Layer | Technology | Purpose (IGCSE focus) |
|---|---|---|
| Content | HTML / XML | Structure and meaning of the page. |
| Presentation | CSS | Colours, fonts, layout, spacing, borders, background images, etc. |
| Behaviour | JavaScript (optional) | Interactivity and dynamic effects – not required for the 0417 syllabus. |
<head> Elements (IGCSE 0417)The syllabus expects the following tags in every web page. They can be written in any order, but the <title> should appear before the external stylesheet links.
<head><meta charset="UTF-8"> <!-- defines character set -->
<title>My School Site</title> <!-- page title shown in the browser tab -->
<meta name="description" content="Brief description of the page">
<meta name="keywords" content="school, news, events">
<meta name="author" content="Your Name">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- makes the page responsive -->
<!-- External style‑sheets – use relative paths and link in the required order -->
<link rel="stylesheet" href="./css/reset.css">
<link rel="stylesheet" href="./css/layout.css">
<link rel="stylesheet" href="./css/theme.css">
</head>
.css file linked with <link rel="stylesheet" href="…"> in the <head>.<style> element in the page’s <head>. Used for page‑specific overrides.style attribute. Highest normal priority.styles.css)/* styles.css – generic presentation rules *//* ---------- background ---------- */
body {
background-color: #f4f4f4; /* light grey page background */
background-image: url("./images/bg.png");/* relative path – works on any server */
background-repeat: no-repeat;
background-position: center center;
}
/* ---------- fonts ---------- */
h1, h2, h3 {
font-family: "Arial", sans-serif;
color: #003366; /* dark blue headings */
}
p, li {
font-family: "Georgia", serif;
font-size: 1rem;
color: #333333; /* dark grey body text */
}
/* ---------- tables ---------- */
table {
border-collapse: collapse; /* single line between cells */
width: 100%;
}
th, td {
border: 1px solid #999999;
padding: 0.5rem;
text-align: center;
vertical-align: middle;
}
<style>/* page‑specific overrides */
h1 { color: #006600; } /* dark green heading for this page */
.highlight { background-color: #ffff99; } /* light yellow highlight */
</style>
<p style="background-color:#ffebcd; color:#8b0000; font-weight:bold;">Important notice…
</p>
| Aspect | External (attached) stylesheet | Inline style attribute |
|---|---|---|
| Typical use | Site‑wide or page‑specific presentation that can be reused. | One‑off styling of a single element. |
| Advantages |
|
|
| Disadvantages |
|
|
| Typical file name | style.css, layout.css etc. | Not a file – written inside the element. |
When several rules could apply to the same element, the browser uses the following order (from lowest to highest priority):
<style> block) – overrides external sheets.!important (advanced use – not required for the syllabus).<head><link rel="stylesheet" href="./css/reset.css">
<link rel="stylesheet" href="./css/layout.css">
<link rel="stylesheet" href="./css/theme.css">
</head>
In this example, a rule p { color: blue; } in theme.css will override a conflicting rule in layout.css because theme.css is linked later.
| Selector type | Syntax | Purpose / Specificity |
|---|---|---|
| Element selector (style) | p { … } | Applies to every <p> element – low specificity. |
| Class selector | .highlight { … } | Reusable set of properties. Applied with class="highlight". Medium specificity. |
| ID selector | #mainHeader { … } | Targets a single, unique element. Applied with id="mainHeader". Higher specificity than a class. |
/* file: tables.css */.table-striped {
border: 1px solid #666666;
border-collapse: collapse;
}
.table-striped tr:nth-child(even) {
background-color: #eaeaea;
}
.table-striped th,
.table-striped td {
padding: 0.4rem 0.6rem;
text-align: left;
}
HTML usage:
<table class="table-striped"><thead>
<tr><th>Name</th><th>Score</th></tr>
</thead>
<tbody>
<tr><td>Alice</td><td>85</td></tr>
<tr><td>Bob</td><td>78</td></tr>
</tbody>
</table>
<div>/* file: layout.css */#sidebar {
width: 250px;
float: right;
background-color: #f0f0f0;
}
<div id="sidebar"><h3>Quick Links</h3>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
background-color – solid colour.background-image – url("path") (use relative paths).background-repeat – repeat, no-repeat, repeat-x, repeat-y.background-position – e.g. center center, top left.font-family – e.g. "Arial", sans-serif.font-size – e.g. 1rem or 16px.font-weight – normal or bold.font-style – normal or italic.text-align – left, center, right, justify.color – named colours or hex values.border, border-width, border-style, border-color.border-collapse: collapse – single line between cells.padding – space inside a cell.margin – space outside the table (rarely used on tables).text-align and vertical-align – horizontal and vertical alignment of cell content.border-spacing – spacing between rows/columns when border-collapse: separate./* headings */h1 { font-family:"Verdana",sans-serif; font-size:2rem; color:#003366; text-align:center; }
h2 { font-family:"Verdana",sans-serif; font-size:1.5rem; color:#004080; }
h3 { font-family:"Verdana",sans-serif; font-size:1.25rem; color:#0055a0; }
/* paragraphs */
p { font-family:"Georgia",serif; font-size:1rem; color:#333333; line-height:1.5; }
/* lists */
ul, ol { margin-left:1.5rem; }
li { margin-bottom:0.3rem; }
/* hyperlinks */
a { color:#0066cc; text-decoration:none; }
a:hover { text-decoration:underline; }
This snippet demonstrates:
<head> meta‑tags..important) and an ID selector (#sidebar) applied to a <div>.<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<title>School Site – IGCSE Example</title>
<meta name="description" content="Sample page for Cambridge IGCSE CSS">
<meta name="keywords" content="IGCSE, CSS, web design">
<meta name="author" content="Your Name">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- External style‑sheets – relative paths – order matters -->
<link rel="stylesheet" href="./css/reset.css">
<link rel="stylesheet" href="./css/layout.css">
<link rel="stylesheet" href="./css/theme.css">
<!-- Internal stylesheet – page‑specific overrides -->
<style>
h1 { color:#660000; } /* dark red heading for this page */
.important { background-color:#ffdddd; } /* light red row highlight */
</style>
</head>
<body style="background-color:#f9f9f9;"> <!-- Inline background for body -->
<h1>Welcome to the School Site</h1>
<p style="font-weight:bold; color:#006600;">
This paragraph uses an inline style to emphasise the text.
</p>
<!-- Example of a
used for grouping and applying an ID selector --><div id="sidebar">
<h3>Quick Links</h3>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
<table class="table-striped">
<thead>
<tr><th>Student</th><th>Score</th></tr>
</thead>
<tbody>
<tr class="important"><td>Alice</td><td>92</td></tr>
<tr><td>Bob</td><td>85</td></tr>
</tbody>
</table>
</body>
</html>
9. Summary Checklist
- Three layers: HTML (content), CSS (presentation), JavaScript (behaviour – optional).
- Required
<head> tags: <title>, charset, description, keywords, author, viewport, and <link> elements for external CSS. - Use relative paths (e.g.
./css/style.css) when linking style‑sheets. - External → internal → inline is the cascade order; later external sheets override earlier ones.
- Element selectors are “styles”; class selectors (
.class) and ID selectors (#id) are reusable and have higher specificity. - The
<div> element groups content and is the most common container for applying classes or IDs. - Remember the key CSS properties required by the syllabus: background, font, colour, text‑align, border, padding, margin, border‑collapse, and table‑specific properties.
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.