h1, h2, h3, p and li elements.<header>, <nav>, <section>, <article>, <aside>, <footer>) together with an external stylesheet.| Layer | Purpose | Typical technology |
|---|---|---|
| Content | Structure and meaning of the page | HTML5 |
| Presentation | How the content looks | CSS |
| Behaviour | Interactivity and dynamic effects | JavaScript (not required for the IGCSE exam) |
Only the content and presentation layers are examined in Cambridge IGCSE 0417. The behaviour layer is mentioned for completeness.
An external stylesheet is a separate file (normally styles.css) that contains all CSS rules for one or more web pages. Benefits:
Place a <link> element inside the <head> of every page that should use the stylesheet.
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A short description of the page for search engines">
<meta name="keywords" content="HTML, CSS, IGCSE, web design">
<meta name="author" content="Your Name">
<title>My Web Page</title>
<link rel="stylesheet" href="css/styles.css"> <!-- relative path – keep the site portable -->
</head>
<body>
…
</body>
</html>
| Type | Example | When to use |
|---|---|---|
| Relative | href="css/styles.css" | Resources stored within the same project – makes the site portable. |
| Absolute | href="https://cdn.example.com/css/styles.css" | Linking to a resource on another domain or a CDN. |
<!DOCTYPE html>, <html>, <head>, <body>charset, viewport, description, keywords, author<header>, <nav>, <section>, <article>, <aside>, <footer><h1>–<h6>, <p>, <ul>, <ol>, <li><a href="url">, id for bookmarks, target="_blank" (optional)<img src="…" alt="…"><video src="…" controls></video><table>, <thead>, <tbody>, <tr>, <th>, <td><div class="…">| Selector | Elements affected | Typical styling |
|---|---|---|
h1 | All <h1> headings | Large, bold, centred title |
h2 | All <h2> headings | Section headings – slightly smaller than h1 |
h3 | All <h3> headings | Sub‑section headings |
p | All paragraph elements | Line‑height, margin, colour |
li | All list items | Bullet/number style, indentation |
/* -------------------------------------------------styles.css – external stylesheet for the demo
------------------------------------------------- */
/* 1. Page title */
h1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 2.5rem;
color: #003366;
text-align: center;
margin-top: 0;
}
/* 2. Section headings */
h2 {
font-family: Verdana, sans-serif;
font-size: 2rem;
color: #006699;
margin-bottom: 0.5rem;
}
/* 3. Sub‑section headings */
h3 {
font-family: Georgia, serif;
font-size: 1.5rem;
color: #0099CC;
margin-top: 1rem;
}
/* 4. Paragraph text */
p {
font-family: "Times New Roman", Times, serif;
font-size: 1rem;
line-height: 1.5;
color: #333333;
margin-bottom: 1rem;
}
/* 5. List items */
li {
font-family: Helvetica, sans-serif;
font-size: 0.95rem;
color: #444444;
margin-left: 1.5rem;
}
/* 6. Flexbox two‑column layout */
.container {
display: flex;
flex-wrap: wrap;
gap: 1rem;
}
.main {
flex: 2 1 60%; /* grow, shrink, basis */
}
.sidebar {
flex: 1 1 30%;
}
/* 7. Responsive headings – media queries */
@media (min-width: 600px) {
h1 { font-size: 3rem; }
h2 { font-size: 2.5rem; }
}
@media (max-width: 599px) {
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
}
/* 8. Accessibility helper – high contrast */
.high-contrast {
color: #000000;
background-color: #FFFFFF;
}
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Demo page for external stylesheet">
<meta name="keywords" content="HTML, CSS, IGCSE">
<meta name="author" content="Your Name">
<title>External Stylesheet Demo</title>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<header>
<h1>My Website Title</h1>
</header>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
<section class="container">
<article class="main">
<h2 id="home">Section Heading</h2>
<p>This paragraph demonstrates the external CSS styling – line‑height, colour and margin.</p>
<h3>Sub‑section</h3>
<p>A list follows:</p>
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
<figure>
<img src="images/photo.jpg" alt="A description of the photo">
<figcaption>Sample image with proper alt text.</figcaption>
</figure>
</article>
<aside class="sidebar">
<h2 id="about">Sidebar</h2>
<p>A short side note. The layout collapses on narrow screens.</p>
</aside>
</section>
<footer>
<p>© 2025 My School – All rights reserved.</p>
</footer>
</body>
</html>
| Method | Syntax example | Pros | Cons |
|---|---|---|---|
| External | <link rel="stylesheet" href="css/styles.css"> | Reusable across pages; cached after first load → faster subsequent pages; easy maintenance. | Extra HTTP request (mitigated by caching and compression). |
| Internal (embedded) | <style> … </style> inside <head> | Only one file to upload; useful for a single‑page demo. | Not reusable; increases page size; harder to keep consistent across multiple pages. |
| Inline | <p style="color:red;">…</p> | Quick for a one‑off change. | Breaks separation of content & presentation; very difficult to maintain; overrides most other rules. |
!important overrides normal rules (use sparingly).1‑0‑0‑00‑1‑0‑00‑0‑1‑00‑0‑0‑1<!-- index.html --><head>
<link rel="stylesheet" href="css/styles.css">
<style>
h2 { color: green; }
</style>
</head>
<body>
<h2 style="color: orange;">Heading</h2>
</body>
Which colour is displayed and why? Answer: orange – the inline style has the highest specificity.
Make headings larger on screens wider than 600 px and smaller on mobile devices.
/* responsive.css – included in styles.css */@media (min-width: 600px) {
h1 { font-size: 3rem; }
h2 { font-size: 2.5rem; }
.sidebar { background-color: #f0f0f0; }
}
@media (max-width: 599px) {
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
.sidebar { background-color: #e8e8e8; }
}
alt text for every <img>.lang="en" (or appropriate language).role="navigation").website. Inside, make sub‑folders css and images.index.html. Adjust the href if you placed styles.css elsewhere.css/styles.css.index.html in a browser – verify layout, colours, and responsive behaviour.styles.css and note which colour appears on all h2 headings:h2 { color: red !important; }Explain why !important overrides the earlier rule.
font-weight of p on small screens.<img src="images/photo.jpg" alt="A description of the photo">Use a colour‑contrast analyser to confirm that body text meets the 4.5:1 ratio.
<link> syntax and required meta tags.h1–h3, p, li.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.