Year 8 · Autumn 2

Building the Web · Lesson 5 of 5

Build a one-page wiki about a favourite game

ProjectTopic 16 The web

Year 8 · Building the Web · Lesson 5 of 5

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.

Year 8 · Building the Web · Lesson 5 of 5

Success criteria

You have got it when you can say:

  • 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.

Year 8 · Building the Web · Lesson 5 of 5

Retrieval starter

Questions from before. Write your answers, then show them.

  1. Last lesson

    Which controls how a page looks?

    A DNSB HTMLC CSS

    C. CSS

  2. Last unit

    In AQA notation, what does A + B mean?

    A A AND BB A OR BC A add B

    B. A OR B

  3. Earlier this unit

    404 means…

    A Not foundB The server crashedC OK

    A. Not found

Year 8 · Building the Web · Lesson 5 of 5

Key words

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 · step 1 of 4 · part 1 of 2

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

The explanation · step 1 of 4 · part 2 of 2

The spec is your checklist (continued)

★Remember

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

The explanation · step 2 of 4 · part 1 of 5

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>

The explanation · step 2 of 4 · part 2 of 5

The whole page (continued)

<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>

The explanation · step 2 of 4 · part 3 of 5

The whole page (continued)

  <h2>Find out more</h2>
  <p><a href="https://en.wikipedia.org/wiki/Tetris">Tetris on Wikipedia</a></p>
</body>
</html>

The explanation · step 2 of 4 · part 4 of 5

The whole page (continued)

  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.

The explanation · step 2 of 4 · part 5 of 5

The whole page (continued)

  1. The <title> shows on the browser tab. The <link> joins the page to its stylesheet.
  2. 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 explanation · step 3 of 4 · part 1 of 4

The stylesheet

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

The explanation · step 3 of 4 · part 2 of 4

The stylesheet (continued)

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

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

img {
  width: 300px;
}

The explanation · step 3 of 4 · part 3 of 4

The stylesheet (continued)

  • 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.

The explanation · step 3 of 4 · part 4 of 4

The stylesheet (continued)

?Why?

Why put the style in a separate file?

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

The explanation · 1 more step

More on the lesson page

The lesson page has the rest of the explanation, step by step:

  • Validate: check every tag

Open the lesson page

Year 8 · Building the Web · Lesson 5 of 5

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.

Year 8 · Building the Web · Lesson 5 of 5

Quick quiz · 1 of 3

In <img src="cat.png" alt="A sleeping cat">, alt is…

  1. A A tag
  2. B An attribute
  3. C A CSS property

B. An attribute

Attributes sit inside the opening tag as name="value". alt describes the image for screen readers.

Year 8 · Building the Web · Lesson 5 of 5

Quick quiz · 2 of 3

A box has width 100px, padding 10px, border 2px, margin 5px. How wide is it on screen, from border edge to border edge?

  1. A 124px
  2. B 134px
  3. C 112px

A. 124px

Content + padding on both sides + border on both sides: 100 + 20 + 4 = 124px. Margin is outside the border.

Year 8 · Building the Web · Lesson 5 of 5

Quick quiz · 3 of 3

The padlock in the address bar tells you…

  1. A The site is honest
  2. B The site has no viruses
  3. C The connection is encrypted with HTTPS

C. The connection is encrypted with HTTPS

It proves the domain and encrypts the traffic. It says nothing about honesty.

Year 8 · Building the Web · Lesson 5 of 5

Exit ticket

Answer on paper before you go. Then check.

  1. When you search, a search engine looks in…

    A Your browser historyB Its index, built earlier by crawlersC The live web, right then

    B. Its index, built earlier by crawlers Crawl → index happen in advance. Searching just looks words up in the index, then ranks the matches.

  2. In https://www.bbc.co.uk/news, the path is…

    A www.bbc.co.ukB /newsC https://

    B. /news The path comes after the domain. It says which page on that server.

Year 8 · Building the Web · Lesson 5 of 5

Homework and the challenge

Homework

Study page 16 to the quiz.

End-of-unit challenge

Build a page to a written spec, then explain in three steps how a search engine would find it.