Know and understand the purpose of the <head> and <body> sections of a web page and how they relate to the three development layers required by the Cambridge IGCSE 0417 syllabus – content, presentation and behaviour.
Every HTML5 page follows the same basic skeleton. The <head> prepares the page (metadata, links, early scripts). The <body> delivers the visible content and interactive features.
<!DOCTYPE html>
<html lang="en">
<head>
…metadata, links, scripts…
</head>
<body>
…visible content, layout, interactive scripts…
</body>
</html>
| Layer | Purpose | Typical technology |
|---|---|---|
| Content | Defines the meaning and structure of information. | HTML (elements in <body> and some in <head> such as <title>, <meta>) |
| Presentation | Controls appearance – colour, fonts, layout, spacing. | CSS (external stylesheet, internal <style>, or inline style attribute) |
| Behaviour | Adds interactivity and dynamic responses. | JavaScript (external <script>, internal, or inline handlers) |
<head> – the “content” layer| Tag | Purpose (one‑sentence description) |
|---|---|
<meta charset="UTF-8"> | Specifies the character encoding; ensures all characters display correctly. |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | Makes the page responsive on mobile devices. |
<meta name="description" content="…"> | Brief summary used by search engines. |
<meta name="keywords" content="HTML, CSS, IGCSE"> | Comma‑separated list of keywords (optional but part of the syllabus). |
<meta name="author" content="Your Name"> | Identifies the page author. |
<base href="https://www.example.com/" target="_blank"> – sets a base URL for relative links (optional).<title>…</title> – appears in the browser tab and search results (must be present).<link rel="icon" href="images/favicon.png" type="image/png"> – favicons for browser tabs.async or defer)| Path type | Example | When to use |
|---|---|---|
| Relative (same folder) | href="styles.css" | Files stored in the same directory as the HTML file. |
| Relative (sub‑folder) | href="css/styles.css" | Typical for organised projects. |
| Root‑relative | href="/assets/css/styles.css" | Useful when the site may be moved to a different domain but keeps the same root structure. |
| Absolute (external) | href="https://cdn.jsdelivr.net/npm/normalize.css" | Only for third‑party CDNs; must include integrity and crossorigin for security. |
integrity="sha384‑…" – Subresource Integrity (SRI) ensures the file has not been tampered with.crossorigin="anonymous" – Required when using SRI with resources from another origin.<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/normalize.css"integrity="sha384‑abc123…" crossorigin="anonymous">
<head> example (with comments)<head>
<!-- 1. Character encoding – must be first -->
<meta charset="UTF-8">
<!-- 2. Viewport for responsive design -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 3. SEO‑relevant meta data -->
<meta name="description" content="Sample IGCSE ICT page showing head and body sections.">
<meta name="keywords" content="HTML, CSS, JavaScript, IGCSE">
<meta name="author" content="Your Name">
<!-- 4. Page title – appears in the browser tab -->
<title>IGCSE ICT – Head & Body Demo</title>
<!-- 5. Optional base URL – sets default target for links -->
<!-- <base href="https://www.example.com/" target="_blank"> -->
<!-- 6. Favicon – small icon shown in tabs/bookmarks -->
<link rel="icon" href="images/favicon.png" type="image/png">
<!-- 7. External stylesheet – presentation layer -->
<link rel="stylesheet" href="css/styles.css"
integrity="sha384‑…"
crossorigin="anonymous">
<!-- 8. Critical JavaScript – load early but do not block rendering -->
<script src="js/critical.js" defer></script>
</head>
<body> – content, presentation and behaviourAll visible elements are placed here: headings, paragraphs, lists, tables, images, audio/video, forms, hyperlinks, and semantic containers such as <section>, <article>, <nav>, <header>, <footer>.
CSS can be added in three ways:
<style> tags (usually in the <head>) for short examples.style attribute on an element (use sparingly).Example of a simple internal style block:
<style>
body {font-family: Arial, sans-serif; line-height: 1.5;}
h1 {color: #2A7AE2;}
.nav {background:#f0f0f0; padding:10px;}
</style>
JavaScript adds interactivity. Three placement options:
<button onclick="alert('Hi')">Click</button><script> tags (commonly placed just before the closing </body> tag).<script src="js/app.js"></script>. Use async or defer to avoid blocking rendering.<h1>Main title</h1>
<h2>Section heading</h2>
<ul>
<li>First item</li>
<li>Second item</li>
</ul>
<table>
<caption>Student marks</caption>
<colgroup>
<col style="width:70%">
<col style="width:30%">
</colgroup>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Score</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alice</td>
<td>85</td>
</tr>
<tr>
<td>Bob</td>
<td colspan="2">78 (rowspan example)</td>
</tr>
</tbody>
</table>
<img src="images/beach.jpg" alt="Sunny beach with palm trees" width="600" height="400">
The alt attribute provides a text alternative for screen readers and for situations where the image cannot be displayed.
<audio controls src="media/song.mp3">Your browser does not support audio.</audio>
<video controls width="640" height="360" src="media/clip.mp4">
Your browser does not support video.
</video>
Always include the controls attribute so users can play, pause and adjust volume.
<form action="submit.php" method="post">
<div>
<label for="name">Name:</label>
<input type="text" id="name" name="name" required aria-required="true">
</div>
<div>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required aria-required="true">
</div>
<div>
<label for="message">Message:</label>
<textarea id="message" name="message" rows="4"></textarea>
</div>
<button type="submit">Send</button>
</form>
<label> is paired with its control via for / id.required and aria-required="true" indicate mandatory fields to assistive technologies.<a href="https://www.cambridgeinternational.org" target="_blank">Cambridge International</a>
<a href="#section2">Jump to Section 2</a>
<h2 id="section2">Section 2</h2>
<header class="site-header">
<h1>My Portfolio</h1>
<nav>
<a href="#about">About</a>
<a href="#projects">Projects</a>
<a href="#contact">Contact</a>
</nav>
</header>
<section id="about">
<h2>About Me</h2>
<p>…</p>
</section>
<article>
<h2>Project Title</h2>
<p>Description of the project.</p>
</article>
<footer>
<p>© 2025 Your Name. All rights reserved.</p>
</footer>
Accessibility
<html lang="en">.alt text for every <img>.<h1> → <h2> …).button, a href).e‑Safety
integrity and crossorigin attributes for any external resources.<head> and <body>| Aspect | <head> | <body> |
|---|---|---|
| Primary role | Provides metadata, links to resources and early scripts – the “content” layer. | Holds visible content and interactive elements – the “presentation” and “behaviour” layers. |
| Visibility to the user | Not rendered in the browser window. | Rendered as page content. |
| Typical elements | <title>, <meta>, <link>, <style>, early <script>, <base> (optional). | All content tags – headings, paragraphs, lists, tables, images, audio/video, forms, navigation, semantic sections, and scripts that run after load. |
| Impact on SEO | Title, description, keywords, author – influence ranking. | Content relevance, heading hierarchy, semantic markup also affect ranking. |
| Loading order | Parsed first; resources may be pre‑loaded. | Parsed after the head; rendered sequentially (scripts with defer run after parsing). |
<!DOCTYPE html>
<html lang="en">
<head>
<!-- 1. Charset – must be first -->
<meta charset="UTF-8">
<!-- 2. Viewport for mobile devices -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 3. SEO meta data -->
<meta name="description" content="Sample IGCSE ICT page showing head and body sections.">
<meta name="keywords" content="HTML, CSS, JavaScript, IGCSE">
<meta name="author" content="Your Name">
<title>IGCSE ICT – Head & Body Demo</title>
<!-- 4. Optional base URL (commented out) -->
<!-- <base href="https://www.example.com/" target="_blank"> -->
<!-- 5. Favicon -->
<link rel="icon" href="images/favicon.png" type="image/png">
<!-- 6. External stylesheet with SRI -->
<link rel="stylesheet" href="css/styles.css"
integrity="sha384‑…"
crossorigin="anonymous">
<!-- 7. Critical JavaScript – defer to avoid blocking -->
<script src="js/critical.js" defer></script>
</head>
<body>
<header class="nav">
<h1>Welcome to My Site</h1>
<nav>
<a href="#section1">Home</a> |
<a href="#section2">Gallery</a> |
<a href="#contact">Contact</a>
</nav>
</header>
<section id="section1">
<h2>About this page</h2>
<p>This paragraph is part of the <code><body></code> section and will be displayed in the browser.</p>
</section>
<section id="section2">
<h2>Image example</h2>
<img src="images/beach.jpg" alt="Sunny beach with palm trees" width="600">
</section>
<section id="contact">
<h2>Contact us</h2>
<form action="submit.php" method="post">
<div>
<label for="name">Name:</label>
<input type="text" id="name" name="name" required aria-required="true">
</div>
<div>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required aria-required="true">
</div>
<button type="submit">Send</button>
</form>
</section>
<footer>
<p>© 2025 Your Name. All rights reserved.</p>
</footer>
<!-- 8. Main JavaScript – placed at end of body for better performance -->
<script src="js/app.js"></script>
</body>
</html>
<head> – it will never be shown.<title> tag – results in a generic browser title and harms SEO.async or defer – delays page rendering.alt text on images – reduces accessibility and SEO.<section>, <article>, <nav>) – makes the page harder to navigate for assistive technologies.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.