Skip to the page
Year 8 · Autumn 2 · Building the Web

Build a one-page wiki about a favourite game

What this lesson covers

Topic 16 The web

KS3 Computing · A web page is text written in HTML (what's on the page), styled with CSS (how it looks), sometimes with JavaScript (what it does). Your browser fetches it from a web server using a URL and HTTP.

Networks and Digital Communication Computational ThinkingCambridge Lower Secondary Computing 0860

You will learn to

  • Use a written spec as a checklist before, during and after building.
  • Create a one-page wiki that meets the spec: heading, three sections, image with alt text, list, link and stylesheet.
  • Identify and fix tags that are missing, misspelt, in the wrong order or not closed.
  • Explain why a few tags, like img, never have a closing tag.

Success criteria

  • I can tick off every line of the spec on my finished page.
  • I can find and fix at least two errors in my HTML.
  • I can show that my stylesheet is linked, because the page changes when I edit style.css.

Key words

Say each word, then read what it means. Every one is in the glossary too.

URL
The full web address of something online.
Protocol
A set of agreed rules for communication.
HTML
Markup language for the content of web pages.
CSS
Language that styles how web pages look.

The explanation

Read it here, or open the study page below to go one step at a time with things to try.

The spec is your checklist

A spec (short for specification) is a list of what the finished work must have.

Read the spec before you start. Check it again at the end.

Spec lineThe HTML that does it
A main heading<h1>
Three sectionsThree <h2> headings, each with some content under it
An image with alt text<img src="…" alt="…">
A list<ul> with an <li> for each item
A link<a href="…">
A stylesheet<link rel="stylesheet" href="style.css"> in the head
★Remember

Build one line of the spec at a time. Save, refresh the browser, and check it before the next line.

The whole page

Here is a finished wiki page. Every spec line is in it.

<!DOCTYPE html>
<html lang="en-GB">
<head>
  <meta charset="utf-8">
  <title>Tetris: a fan wiki</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <h1>Tetris</h1>
  <img src="tetris.png" alt="Coloured blocks falling into a stack">
  <h2>What it is</h2>
  <p>A puzzle game made by Alexey Pajitnov in 1984.</p>
  <h2>How to play</h2>
  <ul>
    <li>Turn and move the falling blocks.</li>
    <li>Fill a whole row to clear it.</li>
    <li>Stop the stack reaching the top.</li>
  </ul>
  <h2>Find out more</h2>
  <p><a href="https://en.wikipedia.org/wiki/Tetris">Tetris on Wikipedia</a></p>
</body>
</html>
  1. <!DOCTYPE html> tells the browser this is a modern HTML page.
  2. lang="en-GB" says the page is in British English. Screen readers use it to choose a voice.
  3. The head holds information about the page. You do not see it on the page itself.
  4. <meta charset="utf-8"> lets the page show characters like é and ñ correctly.
  5. The <title> shows on the browser tab. The <link> joins the page to its stylesheet.
  6. The body holds everything you see on the page.

Indenting means adding spaces at the start of a line. It shows which tags sit inside which. The browser ignores it, but people need it.

!Watch out

Keep index.html, style.css and the image in the same folder. Otherwise the browser cannot find them.

The stylesheet

This is style.css. It sits in the same folder as index.html.

body {
  font-family: Arial, sans-serif;
  background-color: #FDF6E3;
  color: #222222;
}

h1 {
  color: #1A5276;
  text-align: center;
}

img {
  width: 300px;
}
  • The body rule sets the font, the background colour and the text colour for the whole page.
  • The h1 rule makes the main heading dark blue and puts it in the middle.
  • The img rule makes the image 300 pixels wide.
!Watch out

CSS uses American spelling: color, not colour. The browser ignores a rule it cannot read, and shows no error.

?Why?

Why put the style in a separate file?

One stylesheet can style many pages. Change one rule and every page changes.

Validate: check every tag

To validate means to check that the code follows the rules of HTML.

  • Every opening tag has a closing tag with a slash: <p> … </p>.
  • Tags close in the reverse order they opened: <p><strong>…</strong></p>.
  • Attribute values sit inside quotes: alt="A cat".
  • File names match exactly, capitals included.
★Remember

A few tags never close, because nothing goes inside them: <img>, <link>, <meta> and <br>. They are called empty elements.

BugWhat you seeFix
Missing </h2>The text after it looks like a big heading tooAdd </h2> at the end of the heading
Missing </a>Text after the link is clickable tooAdd </a> straight after the link text
Wrong image nameA broken image icon, or only the alt textCheck the spelling, the capitals and the folder
Style.css in the link, style.css in the folderIt may work on your computer, then break on a web serverMatch the capitals exactly
e.g.Example

The free W3C validator at validator.w3.org checks your HTML. Paste your code in, and it lists each error with its line number.

e.g.Worked example

Find and fix the errors. Line 1: <h1>Tetris<h1>. Line 2: <p>A puzzle game from <strong>1984</p></strong>. Line 3: <img src="tetris.png">.

  1. Line 1: the second tag has no slash. Change it to </h1>.
  2. Line 2: the tags close in the wrong order. Close </strong> first, then </p>.
  3. Line 3: the image has no alt text. Add alt="Coloured blocks falling into a stack".
  4. Line 3 needs no closing tag. <img> is an empty element.
  5. Save, refresh the browser, and run the validator again.

Study it

Open the study page and go one step at a time.

Check yourself

One question at a time. The reason shows after each answer.

Saved on this device.