← Teacher guide

Turn the newsletter into cards

Students read a whole newsletter stylesheet and change just the rule that does each job, using rules that combine, links in a menu, block and inline boxes, and the box.

Layout and components · Boxes · about 45 minutes · Open the student lesson

Classroom resources

Load these into Waypoints Prepare: choose Load URL and paste the copied address, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.

Students will be able to

Timing

Read the stylesheet 8 min · Change one rule 8 min · Menu links 10 min · Cards 12 min · Fix the card 5 min

Before class

This is a review lesson: nothing new is taught, and each step uses ideas from earlier lessons. Do the cards step yourself first (about 5 minutes).

The page is a whole document, with the page wrapper from Course A (<!DOCTYPE html>, <head> with the <style> block, <body>). Only the <body> shows. The stylesheet has a group rule, a tag rule that comes after it, a class rule, and later a descendant rule (nav a) and a card class. Students use rules that combine, links in a menu, block and inline boxes, and the box in one page.

Running the lesson

  1. Read the stylesheet: the match is about what each rule changes. For the heading colour, ask which rule comes last and what happens to the property both set.
  2. Change one rule: the check wants a separate h2 rule changed. A student who changes the group rule to orange sees the headings stay teal, because the later rule still wins.
  3. Menu links: ask which links nav a picks before they write it. The link in the story must keep its underline.
  4. Cards: the number is a sum on paper (300 + 40 + 4). Then one class on both sections and one .card rule.
  5. Fix the squashed card: it is the missing unit again, in a whole page.

In class

On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.

The hard part (on purpose)

Choosing which rule to change. Ask them to name the job first, then point to the rule that does it before they type.

When students get stuck

What you will seeA question to askThe fix
The headings stay teal after changing a colour.Which rule comes last for the h2 headings?Change the h2 rule that comes after the group rule, or the later rule still wins.
Every link on the page lost its underline.Is the selector nav a, or just a?Write nav a, with a space, so only links inside the nav change.
The cards do not change.Does the class name in the tags match the name after the dot exactly?Use class="card" on each section, and .card in the CSS with a dot.

Answers to the checks

  1. Match the rules: Match each rule with what it changes.
    body { font-family: sans-serif; } → D. the typeface of all the text on the page; h1, h2 { color: navy; } → C. one rule for the title and the section headings; h2 { color: teal; } → B. a later rule that changes the colour of the section headings only; .note { background-color: lightyellow; } → A. the background of the paragraphs marked note
    Each rule has a job. The group rule colours the title and the headings together, and the h2 rule that comes after it changes just the headings.
  2. Two rules, one heading: Both h1, h2 { color: navy; } and h2 { color: teal; } match the Book fair heading. What colour is it?
    Teal, because the later rule wins where both set the colour
    The heading matches both rules. Both set color, and with equal selectors the later rule wins, so the Book fair heading is teal. The title matches only the first rule, so it stays navy.
  3. Which rule?: Which rule styles only the links inside the nav?
    nav a { }
    A space means inside. nav a picks the links that sit inside the nav and no others.
  4. Block or inline?: The three menu links sit side by side on one line, but the title above them and each section start on a new line. Why?
    Links are inline boxes, and the title and sections are block boxes
    Block boxes (h1, section, div) start a new line and take the full width. Inline boxes (a, strong, span) sit in the line of text, side by side.
  5. Add up a card: A card rule says width: 300px; padding: 20px; border: 2px solid gray; How wide is the card on the page, in pixels?
    344
    300 for the content, plus 20 + 20 of padding, plus 2 + 2 of border: 344.
  6. Fix the squashed card: Maya's cards have a border, but the words touch it, and there is no error. Click the line that causes it.
    line 10
    Line 10 has no unit. padding: 16 means nothing to the browser, so it ignores the whole line. It needs padding: 16px;.

Solutions

One possible solution for each task. Other correct programs are fine.

Change one rule › The headings

<!DOCTYPE html>
<html>
<head>
  <title>School newsletter</title>
  <style>
    body {
      font-family: sans-serif;
    }
    h1, h2 {
      color: navy;
    }
    h2 {
      color: orange;
    }
    .note {
      background-color: lightyellow;
    }
  </style>
</head>
<body>
<header>
  <h1>Library news</h1>
</header>
<main>
  <section>
    <h2>New books</h2>
    <p>The library has 200 new books this term.</p>
  </section>
  <section>
    <h2>Book fair</h2>
    <p class="note">The book fair starts on Monday in the library.</p>
  </section>
</main>
</body>
</html>

Change one rule › The note

<!DOCTYPE html>
<html>
<head>
  <title>School newsletter</title>
  <style>
    body {
      font-family: sans-serif;
    }
    h1, h2 {
      color: navy;
    }
    h2 {
      color: orange;
    }
    .note {
      background-color: lightpink;
    }
  </style>
</head>
<body>
<header>
  <h1>Library news</h1>
</header>
<main>
  <section>
    <h2>New books</h2>
    <p>The library has 200 new books this term.</p>
  </section>
  <section>
    <h2>Book fair</h2>
    <p class="note">The book fair starts on Monday in the library.</p>
  </section>
</main>
</body>
</html>

Style the menu links › Which rule?

Open task: any program that does what the step asks.

Style the menu links › Block or inline?

Open task: any program that does what the step asks.

Style the menu links › The menu rule

<!DOCTYPE html>
<html>
<head>
  <title>School newsletter</title>
  <style>
    body {
      font-family: sans-serif;
    }
    h1, h2 {
      color: navy;
    }
    h2 {
      color: teal;
    }
    header {
      background-color: lightblue;
      padding: 16px;
    }
    nav a {
      color: navy;
      text-decoration: none;
    }
  </style>
</head>
<body>
<header>
  <h1>Library news</h1>
  <nav>
    <a href="https://example.com/home">Home</a>
    <a href="https://example.com/events">Events</a>
    <a href="https://example.com/join">Join</a>
  </nav>
</header>
<main>
  <section>
    <h2>New books</h2>
    <p>The library has 200 new books this term. See the <a href="https://example.com/list">full list</a>.</p>
  </section>
</main>
</body>
</html>

Turn the sections into cards › Add up a card

Open task: any program that does what the step asks.

Turn the sections into cards › Share a class

<!DOCTYPE html>
<html>
<head>
  <title>School newsletter</title>
  <style>
    body {
      font-family: sans-serif;
    }
    h1, h2 {
      color: navy;
    }
    h2 {
      color: teal;
    }
  </style>
</head>
<body>
<header>
  <h1>Library news</h1>
</header>
<main>
  <section class="card">
    <h2>New books</h2>
    <p>The library has 200 new books this term.</p>
  </section>
  <section class="card">
    <h2>Book fair</h2>
    <p>The book fair starts on Monday in the library.</p>
  </section>
</main>
</body>
</html>

Turn the sections into cards › One rule for the cards

<!DOCTYPE html>
<html>
<head>
  <title>School newsletter</title>
  <style>
    body {
      font-family: sans-serif;
    }
    h1, h2 {
      color: navy;
    }
    h2 {
      color: teal;
    }
    .card {
      padding: 16px;
      border: 2px solid gray;
      margin: 16px 0;
    }
  </style>
</head>
<body>
<header>
  <h1>Library news</h1>
</header>
<main>
  <section class="card">
    <h2>New books</h2>
    <p>The library has 200 new books this term.</p>
  </section>
  <section class="card">
    <h2>Book fair</h2>
    <p>The book fair starts on Monday in the library.</p>
  </section>
</main>
</body>
</html>

Stretch and support

Stretch: Add a second class, `.featured`, with a different border colour, and put it on the headline section as well as card. Which border wins, and why?

Support: Give students only the Change one rule and Turn the sections into cards steps, and a copy of the page with the class already on both sections.

Exit ticket

A page has h1, h2 { color: navy; } and then h2 { color: teal; }. What colour is an h2, and what colour is the h1?

The h2 is teal, because the later rule wins where both set the colour. The h1 matches only the first rule, so it is navy.

What each step is for

Where it leads

Next unit is Layout: Flexbox puts boxes in a row, such as a menu. Class idea: ask students to find three cards on a real website and sketch their padding, border and margin.