Students build a hero and a row of cards from classes, copy a card's HTML to add another, and find out that one set of rules styles every copy.
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.
Predict and Run 10 min · Investigate 10 min · Mix it up 5 min · Modify 8 min · Make 12 min
Do the Make task yourself in the playground (about 6 minutes).
A component here means a chunk of HTML with a class that you copy: a card, or a hero (a big opening section). Nothing new is taught: it is the class, box and flex row from earlier lessons, used on purpose. The idea is that one rule styles every copy, so adding a card is copying HTML.
The usual slip is writing a new class and rule for each copy (card1, card2). It works, but every change has to be made in each rule.
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.
With your partner, decide how many lines of CSS you would write for the fourth card. Hold up 0, 1, 5 or 10 fingers for your answer.
Take the vote before running. Ask a student who said 5 what the new rule would say, and how it differs from .card. The idea to land: it would say the same.
Swap pages with a partner. Add a card to their page by copying only HTML, without changing any rule. Check that it looks like the others.
Watch for students who start to type CSS. Ask what the new card has that the others have.
Believing each copy needs its own rule. Ask what the new card has in common with the others before they write any CSS.
| What you will see | A question to ask | The fix |
|---|---|---|
| A copied card looks plain. | Does the copy have the same class, spelt the same? | Check class="card" on the copy. A different spelling, such as crad, matches no rule, and the browser shows no error. |
| The student has .card1, .card2 and .card3 rules. | How many lines of CSS would a tenth card need? | Give every card the class card, keep one .card rule, and delete the numbered ones. |
| The cards stay in one squashed line. | Does the row wrap, and do the cards have a minimum width? | Add flex-wrap wrap to the .cards rule and a min-width to the .card rule. |
One possible solution for each task. Other correct programs are fine.
<style>
.hero {
padding: 24px;
background-color: lightblue;
}
.cards {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.card {
flex: 1;
min-width: 150px;
padding: 16px;
border: 2px solid navy;
}
</style>
<section class="hero">
<h1>Robotics Club</h1>
<p>Build, code and compete every Tuesday.</p>
<a href="https://example.com/join">Join us</a>
</section>
<div class="cards">
<section class="card"><h2>Robots</h2><p>Build and test.</p></section>
<section class="card"><h2>Coding</h2><p>Make games.</p></section>
</div>
<style>
.hero {
padding: 24px;
background-color: lightblue;
}
.cards {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.card {
flex: 1;
min-width: 150px;
padding: 16px;
border: 2px solid navy;
}
</style>
<section class="hero">
<h1>Robotics Club</h1>
<p>Build, code and compete every Tuesday.</p>
<a href="https://example.com/join">Join us</a>
</section>
<div class="cards">
<section class="card"><h2>Robots</h2><p>Build and test.</p></section>
<section class="card"><h2>Coding</h2><p>Make games.</p></section>
<section class="card"><h2>Drones</h2><p>Fly and film.</p></section>
</div>
<style>
.hero {
padding: 24px;
background-color: lightblue;
}
.cards {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.card {
flex: 1;
min-width: 150px;
padding: 16px;
border: 1px solid gray;
}
</style>
<section class="hero">
<h1>Robotics Club</h1>
<p>Build, code and compete every Tuesday.</p>
<a href="https://example.com/join">Join us</a>
</section>
<div class="cards">
<section class="card"><h2>Robots</h2><p>Build and test.</p></section>
<section class="card"><h2>Coding</h2><p>Make games.</p></section>
<section class="card"><h2>Design</h2><p>Draw a logo.</p></section>
<section class="card"><h2>Drones</h2><p>Fly and film.</p></section>
</div>
Stretch: Add a second component, a footer with a class, and use it on two pages worth of text. Or give the cards a third kind, card featured, that changes only the border colour.
Support: Give students the Run page and ask them only to add two cards by copying, and change one colour in the rule.
A page has ten cards, all class card. How many .card rules does it need, and how do you add an eleventh card?
One rule. Copy the HTML of a card, change its words, and the rule already styles it.
Next is the Course B challenge, which lays out the club page using everything so far. Class idea: look at a shop website and point out the parts that are the same component repeated.