class attributes to any HTML element.<head> elements (meta‑tags, charset, viewport, title, external stylesheet) in a valid HTML5 document.:hover).| Layer | Purpose | Typical tags / techniques |
|---|---|---|
| Content layer | Defines the structure and meaning of the page. |
|
| Presentation layer | Controls how the content looks. | CSS (external, embedded, inline), class and ID selectors, pseudo‑classes. |
| Behaviour layer | Enables interactivity (not required for the IGCSE). | Presence of a <script> element is allowed, but no scripting is examined. |
<head> (syllabus 21.2)Only the three items below are mandatory for the exam. The others are useful in real‑world sites but are not examined.
| Element | Typical syntax | Exam relevance |
|---|---|---|
<title> | <title>My Page</title> | Required – appears in the browser tab and is checked by the examiner. |
<meta charset="UTF-8"> | <meta charset="UTF-8"> | Required – ensures correct character display. |
<meta name="viewport" content="width=device-width, initial-scale=1"> | <meta name="viewport" content="width=device-width, initial-scale=1"> | Required – makes the page responsive on mobile devices. |
<link rel="stylesheet" href="css/styles.css"> | <link rel="stylesheet" href="css/styles.css"> | Required – links the external style sheet (exam‑friendly relative path). |
Optional but useful meta‑tags (not examined): description, author. The keywords meta‑tag is deprecated in HTML5 and can be omitted.
<head> section<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Demonstrates CSS classes for IGCSE">
<meta name="author" content="Your Name">
<title>Class Example</title>
<link rel="stylesheet" href="css/styles.css">
</head>
| Type | Syntax | When to use (exam) |
|---|---|---|
| External | <link rel="stylesheet" href="styles.css"> | Preferred – separates content from presentation, reusable, demonstrates relative paths. |
| Embedded (internal) | <style> … </style> inside <head> | Useful for a single‑page demonstration; still separate from HTML markup. |
| Inline | <p style="color:red;">…</p> | Allowed but discouraged – mixes content with presentation and cannot be reused. |
class attribute inside the opening tag.<div class="highlight">Important text</div><p class="note warning">Check this warning</p>
<span class="bold italic red">Styled text</span>
Each class contributes its own declarations; the final appearance is the combination of all matching rules, resolved by the cascade.
| Rule | Example / Reason |
|---|---|
| Use lowercase letters | menu-item |
| Separate words with hyphens | Improves readability; avoid _ or camelCase. |
| Be descriptive, not presentational | error-message (not red-text) |
| Avoid reserved words | Do not use class, id, html, etc. |
.highlight { background-color:#ff0; }.note { font-size:0.9em; }
.warning { color:#c00; }
| Selector | Specificity | Explanation |
|---|---|---|
#header | (1,0,0) | One ID selector. |
.nav-link | (0,1,0) | One class selector. |
p | (0,0,1) | One type selector. |
ul li.active:hover | (0,2,2) | Two class/pseudo‑class selectors and two type selectors. |
!important overrides normal rules (use sparingly).(a,b,c) wins./* stylesheet1.css – linked first */p { color:#555; } /* (0,0,1) */
.highlight { color:#006; } /* (0,1,0) */
/* stylesheet2.css – linked second */
.highlight { color:#c00; } /* same specificity, later sheet wins */
All <p class="highlight"> elements will appear red because the second stylesheet overrides the first.
.title {font-family: Arial, sans-serif;
color: #003366;
margin-bottom: 1rem;
}
.intro {
font-size: 1.1em;
line-height: 1.5;
}
.highlight {
background-color: #ffff99;
padding: 0.3rem;
}
<table class="data-table"><tr><th>Item</th><th>Price</th></tr>
<tr><td>Apple</td><td>$1</td></tr>
</table>
.data-table {border-collapse: collapse;
width: 100%;
}
.data-table th,
.data-table td {
border: 1px solid #999;
padding: 0.5rem;
text-align: left;
}
.data-table th {
background-color: #f0f0f0;
}
.nav-link {display: inline-block;
padding: 0.4rem 0.8rem;
color: #333;
text-decoration: none;
}
.nav-link:hover {
background-color: #e0e0e0;
color: #000;
}
.active {
background-color: #003366;
color: #fff;
}
src="images/logo.png"src="images/icons/home.svg"href="../styles/main.css"Absolute URLs (e.g. http://example.com/logo.png) should be avoided in exam questions because they break when the site is moved.
<a id="top"></a> ...
<a href="#top">Back to top</a>
Bookmarks aid navigation and are part of the required hyperlink knowledge.
class="nav-linkactive").menu-item vs menu_item).project/
└─ css/styles.css
└─ index.html
index.html) – include the required <head> elements and link the external stylesheet.class="title", class="intro highlight").css/styles.css.<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Demonstrates CSS classes for IGCSE">
<meta name="author" content="Your Name">
<title>Class Example</title>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<a id="top"></a> <!-- bookmark destination -->
<h1 class="title">Welcome to My Site</h1>
<p class="intro highlight">This paragraph uses two classes.</p>
<nav>
<a href="#section1" class="nav-link">Section 1</a>
<a href="#section2" class="nav-link active">Section 2</a>
<a href="#section3" class="nav-link">Section 3</a>
</nav>
<section id="section1">
<h2 class="subtitle">First Section</h2>
<table class="data-table">
<tr><th>Item</th><th>Price</th></tr>
<tr><td>Apple</td><td>$1</td></tr>
</table>
</section>
<!-- more sections … -->
<p><a href="#top">Back to top</a></p>
</body>
</html>
/* 1. General page styling */body {
font-family: Arial, sans-serif;
margin: 0;
padding: 1rem;
line-height: 1.5;
}
/* 2. Text classes */
.title {
color: #003366;
margin-bottom: 1rem;
}
.intro {
font-size: 1.1em;
}
.highlight {
background-color: #ffff99;
padding: 0.3rem;
}
/* 3. Navigation */
.nav-link {
display: inline-block;
padding: 0.4rem 0.8rem;
color: #333;
text-decoration: none;
}
.nav-link:hover {
background-color: #e0e0e0;
}
.active {
background-color: #003366;
color: #fff;
}
/* 4. Table styling */
.data-table {
border-collapse: collapse;
width: 100%;
margin-top: 1rem;
}
.data-table th,
.data-table td {
border: 1px solid #999;
padding: 0.5rem;
text-align: left;
}
.data-table th {
background-color: #f0f0f0;
}
Although the IGCSE does not assess JavaScript, the syllabus mentions the <script> element as part of the behaviour layer. In exam answers you may simply state that no scripting is required and that the <script> tag would be placed just before the closing </body> if it were needed.
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.