Students link Bootstrap's stylesheet, predict that a class name with no rule of their own still styles a button, match classes to what they do, find a button missing its base class, and style a notice for an event of their own.
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 15 min · Modify 10 min · Make 15 min
Read the unit primer first. Bootstrap is a stylesheet: one big CSS file of ready-made rules (about 230 KB). Linking it with <link rel="stylesheet" href="bootstrap.min.css"> gives the page all its rules; adding a class name such as btn switches one on. Nothing new happens in the browser: students already know classes and CSS rules from HTML & CSS; the rules are just someone else's.
Most looks come in two parts, a base class for the shape (btn, alert) and a second for the colour or size (btn-primary, btn-lg). The planted bug leaves out the base class. Here the stylesheet sits beside the page (it is served from this site); on a real site, download it from getbootstrap.com. This course uses Bootstrap's CSS only, not its JavaScript, so nothing needs a script.
Students want to write CSS to fix a look. Ask "which Bootstrap class does that?" and send them to the Reference drawer before they type a rule.
| What you will see | A question to ask | The fix |
|---|---|---|
| Nothing looks like Bootstrap. | Is the link line there, at the top, spelt bootstrap.min.css? | Put the link line first, exactly as in the lesson. |
| A button keeps the browser's grey look. | Does its class have btn as well as a colour? | class="btn btn-success": the base class and the colour. |
| A class does nothing, such as btn-green. | Is that name in Bootstrap's list? | Use the names on the Reference cards (success is green); made-up names are ignored. |
One possible solution for each task. Other correct programs are fine.
<link rel="stylesheet" href="bootstrap.min.css">
<div class="container mt-3">
<h1>Chess club</h1>
<p class="lead">Chess every Wednesday at lunch in the library.</p>
<div class="alert alert-warning">Sign-ups close on Friday.</div>
<button class="btn btn-success btn-lg">Join</button>
<button class="btn btn-outline-secondary">Read more</button>
</div>
<link rel="stylesheet" href="bootstrap.min.css">
<div class="container mt-3">
<h1>Chess club</h1>
<div class="alert alert-danger">The tournament is full.</div>
<p class="lead">Chess every Wednesday at lunch in the library.</p>
<div class="alert alert-warning">Sign-ups close on Friday.</div>
<button class="btn btn-primary">Join</button>
<button class="btn btn-outline-secondary">Read more</button>
</div>
<link rel="stylesheet" href="bootstrap.min.css">
<div class="container mt-3">
<h1>Art show</h1>
<p class="lead">Year 8 paintings in the hall, Thursday after school.</p>
<div class="alert alert-info">Families welcome. Entry is free.</div>
<button class="btn btn-primary">Sign up</button>
<button class="btn btn-outline-secondary">More</button>
</div>
Stretch: Use btn-sm and btn-lg, outline buttons (btn-outline-danger), and the text colour classes (text-success). Try a badge: span class="badge text-bg-secondary".
Support: Give the class names on the board for the Make task and ask students only to place them.
Why does class="btn btn-primary" make a blue button when you wrote no CSS?
The linked stylesheet, bootstrap.min.css, has rules for btn and btn-primary; the class names switch them on.
Next: the navbar, cards and grid, where Bootstrap parts are whole shapes of nested tags. Class idea: put the hand-built club page and this page side by side and count the lines of CSS.