Practice Paper
A full practice exam: 90 minutes, five parts, 100 points — and every answer, behind a button. Do it on paper first.
How to use it
- Copy it onto paper, or print this page. The real exam is on paper.
- Set a timer for 90 minutes. The suggested times add up to 84 — the rest is for checking.
- Answer everything before you open a single answer. An answer you have read is not one you know.
- Then mark yourself. For every point you lost, find the slide that covers it.
This is not the real exam, and the real points will be different. It practises the same things: reading code, telling the three languages apart, finding what is wrong, and explaining it. Nothing in it asks you to write code.
The code is shown without colours, as it will be on paper.
| Part | Points | Time | |
|---|---|---|---|
| A | How the web works | 15 | 12 min |
| B | HTML, CSS or JavaScript? | 15 | 12 min |
| C | Read the code | 30 | 25 min |
| D | Find the errors | 30 | 25 min |
| E | Your project, your tools | 10 | 10 min |
| Total | 100 | 84 min |
Part A · How the web works
15 points · about 12 minutes
A1 · Four inventions (8 points)
In 1989, Tim Berners-Lee proposed the Web at CERN. To make it work, he had to invent four things. Name all four. For each one, say what it was for — and spell out the acronym where there is one.
Show the answer
| Invention | Spelled out | What it was for |
|---|---|---|
| HTML | HyperText Markup Language | a way to write the documents |
| HTTP | HyperText Transfer Protocol | a way to transmit them |
| URL | Uniform Resource Locator | a way to address them |
| the browser | — | a way to read them. His was called WorldWideWeb |
Two points each: one for the name and what it stands for, one for what it was for.
A2 · An address (4 points)
https://shop.example.com/menu/drinks.html?lang=en#tea
- What is
shop.example.com? - What is
/menu/drinks.html? - What is
?lang=en? - Which part of the address does the server never see?
Show the answer
- The host — which machine. (
example.cominside it is the domain: who owns it.) - The path — which resource on that machine.
- The query — parameters sent along with the request.
- The fragment,
#tea. The browser keeps it; it is never sent to the server.
A3 · Status codes (3 points)
- What does a 404 mean, and whose fault is it?
- What does a 500 mean, and whose fault is it?
- Your site goes live. On your laptop every image showed; online, every image is missing. What is the likeliest cause?
Show the answer
- Not found. The server looked, and the file is not there. A 4xx is the requester's mistake — usually a wrong address.
- Server error. The server broke. A 5xx is the server's mistake.
- Capitals in the file names or paths —
Hero.JPGon disk,hero.jpgin the HTML. Windows and macOS ignore the difference; the Linux server does not, and answers 404. (A path to your own disk, such asC:\…, is also accepted.)
Part B · HTML, CSS or JavaScript?
15 points · about 12 minutes
B1 · Name the language (8 points)
Name the language of each line. If a line holds two languages, name both.
1 <link rel="stylesheet" href="style.css">
2 .quote { border-left: 4px solid #c2410c; }
3 document.getElementById('site-header').innerHTML = html;
4 <p style="color: grey;">Built by Li Wei</p>
5 <!-- one article per quote -->
6 let likes = 0;
7 nav a:hover { color: #c2410c; }
8 <script src="nav.js"></script>
Show the answer
- HTML — it links a CSS file, but the line is an HTML element.
- CSS
- JavaScript
- HTML and CSS — an HTML paragraph, with CSS in its
styleattribute. - HTML — an HTML comment.
- JavaScript
- CSS
- HTML — an element that loads a JavaScript file.
One point each.
B2 · Which layer? (5 points)
For each problem, say where you would look first, and why.
- The page shows no colours and no fonts at all — plain black on white.
- A paragraph, and everything after it, appears big and bold, like a heading.
- The like button looks right, but nothing happens when you click it.
- One rule in
style.cssis ignored; all the others work. - The navigation appears when you use Live Server, but not when you double-click
index.html.
Show the answer
- The
<link>to the stylesheet — the file name or the path is wrong, so no CSS arrives at all. - HTML — a heading tag that was never closed.
- JavaScript — appearance is fine, behaviour is not. Open the Console.
- CSS — a typo in that rule: a misspelled property, a missing
;or a missing unit. DevTools → Styles shows it struck through. - How the page is opened. A double-click opens it with
file://, andfetchneeds a server — the browser blocks it. Nothing is wrong with the code.
One point each.
B3 · Why keep them apart? (2 points)
HTML, CSS and JavaScript usually live in separate files. Give two reasons.
Show the answer
Any two:
- Changing one CSS file changes the look of every page.
- A screen reader reads the HTML and ignores the presentation.
- When something breaks, you know which file to open.
- The browser caches the CSS file, so it is downloaded once for the whole site.
Part C · Read the code
30 points · about 25 minutes
Questions C1 to C13 are about these two files.
about.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>About · Mei Lin</title>
<link rel="icon" href="favicon-32.png" sizes="32x32">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<nav>
<a href="index.html">Home</a>
<a href="photos.html">Photos</a>
<a href="about.html">About</a>
</nav>
</header>
<main>
<h1>About me</h1>
<p class="intro">I photograph the coast of Hainan.</p>
<p>My favourite place is <strong>Wenchang</strong>.</p>
<h2>How I work</h2>
<ol>
<li>Walk</li>
<li>Wait</li>
<li>Take one picture</li>
</ol>
<img src="images/boats.webp" alt="Fishing boats on the beach at Wenchang, at sunrise">
</main>
<footer id="site-footer">
<p>Contact: <a href="mailto:mei@example.com">mei@example.com</a></p>
</footer>
</body>
</html>
style.css
body {
font-family: Georgia, serif;
color: #333;
}
main {
max-width: 40rem;
margin: 0 auto;
}
.intro {
font-size: 1.25rem;
color: #0369a1;
}
nav {
display: flex;
gap: 1rem;
}
nav a:hover {
color: red;
}
#site-footer {
border-top: 1px solid #ccc;
padding: 1rem;
}
img {
max-width: 100%;
}
C1 · The tab (2 points)
What text appears in the browser tab, and which element puts it there?
Show the answer
About · Mei Lin — from the <title> element in the head.
C2 · Two lines in the head (2 points)
The charset line and the viewport line are deleted. What goes wrong without each?
Show the answer
- Without the charset: characters outside plain English — 中文, emoji — can turn to nonsense.
- Without the viewport: a phone shows the page at desktop width, shrunk until it is tiny.
C3 · head and header (2 points)
The page has a <head> and a <header>. What is the difference?
Show the answer
<head> is about the page: nobody sees it, it sits above <body>, and it holds the title, the charset, the favicon and the stylesheet.
<header> is the top of the page: everybody sees it, it sits inside <body>, and here it holds the navigation.
C4 · The parts of the page (3 points)
Name the four parts this page is made of. Which one changes from page to page?
Show the answer
<header>, <nav>, <main> and <footer>. Only <main> changes from page to page; the other three are the same on every page.
C5 · The list (2 points)
Why is the list under How I work an <ol> and not a <ul>?
Show the answer
The order is the information — they are steps. Shuffle them and something is lost. A <ul> is for lists whose order does not matter.
C6 · The image (2 points)
What is the alt text for? Is this one good — and why?
Show the answer
It describes the image for people who cannot see it — a screen reader reads it aloud, and it appears if the image fails to load.
This one is good: it says what the picture shows, specifically — as if describing it to someone on the phone.
C7 · strong (2 points)
What would change if <strong>Wenchang</strong> were written <b>Wenchang</b>?
Show the answer
On screen, nothing — both are bold. But <strong> says the word is important, and a screen reader can say it differently. <b> is bold pixels with no meaning.
C8 · What each rule picks (5 points)
Which element or elements on this page does each selector pick?
main.intronav a:hover#site-footerimg
Show the answer
- The
<main>element — everything between the header and the footer. - The paragraph I photograph the coast of Hainan. — the only element with
class="intro". - The three links in the
<nav>— each one only while the mouse is over it. - The
<footer>— the only element withid="site-footer". - The photo of the fishing boats.
One point each.
C9 · The content column (2 points)
What do max-width: 40rem and margin: 0 auto do to <main>?
Show the answer
max-width stops the content column from growing wider than 40rem, however wide the screen is. margin: 0 auto puts equal space on its left and right, so the column sits in the centre.
C10 · The navigation (2 points)
What does display: flex do to the <nav>?
Show the answer
It puts the children of the <nav> — the three links — side by side in a row, with 1rem between them.
C11 · Text or box? (2 points)
The .intro rule sets color: #0369a1. What turns that colour — the text of the paragraph, or the box behind it?
Show the answer
The text. color is always the text colour. The box behind it would be background-color.
C12 · The footer (2 points)
The #site-footer rule sets a border-top and a padding. What does each one do?
Show the answer
border-top draws a thin grey line along the top edge of the footer. padding puts space inside the footer, between that line and the text.
C13 · hover (2 points)
Move the mouse over the email address in the footer. Does it turn red? Why or why not?
Show the answer
No. nav a:hover only picks links inside the <nav>. The email link is in the footer.
Part D · Find the errors
30 points · about 25 minutes
D1 · Six errors in HTML (12 points)
For each error, give the line number, say what is wrong, and say what would fix it.
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="UTF-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 <title>Wenchang Eats</title>
7 <link rel="stylesheet" href="style.css">
8 </head>
9 <body>
10 <header>
11 <nav>
12 <a href="index.html">Home</a>
13 <a href="menu.html>Menu</a>
14 <a href="contact.html">Contact</a>
15 </nav>
16 </header>
17 <main>
18 <h1>Where the locals eat</h1>
19 <h2>Three dishes worth the trip
20 <p>Chosen by students who live here.</p>
21 <img src="images\coconut-chicken.webp" alt="Coconut chicken in a clay pot">
22 <img src="images/rice-noodles.webp">
23 <ul>
24 <li>Coconut chicken</li>
25 <li>Wenchang chicken rice</li>
26 <li>Hainan rice noodles</li>
27 </ul>
28 <p>Open <strong>every day</p></strong>
29 </main>
30 <footer>
31 <li><a href="mailto:hello@example.com">hello@example.com</a></li>
32 </footer>
33 </body>
34 </html>
Show the answer
- Line 13: the quote after
menu.htmlis never closed. The address swallows the text after it — the Menu link vanishes and the Contact link goes to the wrong place. Fix:href="menu.html". - Line 19: the
<h2>is never closed. Everything after it, down to the end of<main>, becomes part of the heading — big and bold. Fix:</h2>at the end of the line. - Line 21: a backslash in the path. Addresses use forward slashes; the validator rejects
\. Fix:images/coconut-chicken.webp. - Line 22: no
alt. Fix: add one that says what the photo shows, such asalt="A bowl of Hainan rice noodles". - Line 28: closed in the wrong order.
<strong>opened inside<p>, so it must close first. Fix:</strong></p>. - Line 31: a
<li>outside a list. A list item belongs inside<ul>or<ol>. Fix: use<p>or<address>instead — or wrap it in a<ul>.
Two points each: one for finding it, one for what is wrong and how to fix it.
D2 · Five errors in CSS (10 points)
The HTML this styles uses <article class="quote"> for each quote. For each error, give the line number, say what is wrong, and say what would fix it.
1 body {
2 font-family: system-ui, sans-serif;
3 colour: #1f2937;
4 }
5
6 // the content column
7 main {
8 max-width: 48rem;
9 margin: 0 auto;
10 }
11
12 .Quote {
13 padding: 1.5rem;
14 border-left: 4px solid #c2410c;
15 }
16
17 h1 {
18 font-size: 32 px;
19 color: #c2410c
20 margin-bottom: 1rem;
21 }
22
23 nav a {
24 text-decoration: none;
25 color: #334155;
26 }
Show the answer
- Line 3:
colour. CSS spells itcolor. As it is, the declaration is ignored. - Line 6:
//is not a CSS comment. It becomes part of the next selector, and the wholemainrule breaks. Fix:/* the content column */. - Line 12:
.Quotewith a capital Q. Class names are case-sensitive and the HTML saysquote, so this matches nothing. Fix:.quote. - Line 18: a space in
32 px. Ignored. Fix:32px. - Line 19: no semicolon. The browser reads
#c2410c margin-bottom: 1remas one value, so both lines are lost. Fix: add;.
Two points each.
D3 · Paths and names (8 points)
The site is a folder called my-site, holding index.html, about.html, style.css and a folder images with hero.webp and beach day.webp in it. The page about.html has a section with id="contact". The site is going live on a Linux server.
Mark each line from index.html correct (✓) or wrong (✗). For each wrong one, say why.
1 <img src="images/hero.webp" alt="...">
2 <img src="Images/hero.webp" alt="...">
3 <img src="C:\Users\mei\Desktop\my-site\images\hero.webp" alt="...">
4 <img src="www.example.com/photo.webp" alt="...">
5 <img src="images/beach day.webp" alt="...">
6 <a href="https://developer.mozilla.org">MDN</a>
7 <a href="about.html#contact">Contact</a>
8 <link rel="stylesheet" href="styles.css">
Show the answer
- ✓
- ✗ A capital I. The folder is
images. It works on a laptop and breaks on the server. - ✗ A path on your own disk. The server — and every visitor — has no
C:drive of yours. - ✗ No
https://. The browser treats it as a folder calledwww.example.cominside your site. - ✗ A space in the file name. It becomes
%20, and the validator rejects it. Rename the filebeach-day.webp. - ✓ an absolute address, for another site
- ✓ a page, and a place on it
- ✗ The file is
style.css, notstyles.css. No styling at all.
One point each.
Part E · Your project, your tools
10 points · about 10 minutes
E1 · The Open Graph image (3 points)
What is an Open Graph image? Where do people see it, and what size is it?
Show the answer
The picture on the preview card that appears when a link to your site is shared in a chat app or a social network — with your title and one sentence. It is 1200 × 630 pixels. Without it, the card is a grey box, or nothing.
E2 · Three lines from a head (3 points)
Say what each line does.
1 <link rel="icon" href="favicon-32.png" sizes="32x32">
2 <link rel="apple-touch-icon" href="apple-touch-icon.png">
3 <meta property="og:image" content="https://mei.example.com/images/og-image.jpg">
Show the answer
- The favicon — the small square picture in the browser tab, in bookmarks and in history. 32 × 32.
- The app icon — shown on a phone's home screen when someone saves the site. 180 × 180, a separate file.
- The Open Graph image — the picture on the preview card when the link is shared. It needs the full
https://address, because the app showing the card fetches it from somewhere else.
E3 · Git (4 points)
- What is the difference between Git and GitHub? (2 points)
- Put these three commands in order, and say what each one does:
git push·git add·git commit(2 points)
Show the answer
- Git is a program on your computer: it records the history of a folder, and works offline. GitHub is a website: it keeps a copy of that history online, where others can see it. You can use Git without GitHub, but not GitHub without Git.
git add— choose which changes go into the next commit.git commit— record them, as a snapshot with a message.git push— send the new commits up to GitHub.
After you mark it
For every question you lost points on, find where it was taught: