← Teacher guides

Teacher guide: Pages with Bootstrap

Rebuild the club page with Bootstrap's ready-made parts: buttons, a navbar, cards, a grid and a form, styled by class names instead of your own CSS. Then compare it with the hand-built page and make Bootstrap look like yours.

Open the student course · How the ideas build

Each lesson works two ways. Students can work through the online tutorial at their own pace (it checks their answers and saves their progress in their browser), or you can teach it to the whole class from the slides, then send students into the tutorial for the Modify and Make steps.

Every lesson guide has plain-language notes, the answers to every check, a solution for every task, and slides and a worksheet for Waypoints Prepare. These guide pages are not linked from student pages, but they are not secret either: keep printed Teacher editions for answers you do not want students to find.

Strategies for getting unstuck: Say what it should do, Test a small piece, Read the error, Trace it. A student who is stuck can try one before asking for a hint. The optional course How you learn best introduces them, and a few lesson decks have a short teach, show or nudge slide for one. (Each lesson page links to the cards from its first hint.)

Whole-course cheat sheet: Open to print (every command, grouped by unit: a handout for the final challenge)

Ready-made parts

Link Bootstrap's stylesheet, style by class names, rebuild the club page's parts, then put your own CSS on top.

Bootstrap in 5 minutes (read before teaching this unit)

The idea in plain words

Bootstrap is a stylesheet: one big CSS file that someone else wrote, full of rules for buttons, menus, cards, forms and a layout grid. A page links it with one line, <link rel="stylesheet" href="bootstrap.min.css">, and then styles tags by adding its class names: class="btn btn-primary" makes a blue button. Students write no CSS for it; they look the names up. Each larger part is a shape of nested tags (a row holds cols, a card holds a card-body) that they copy and fill in. Their own rules go after the link, because when two rules match equally the later one wins.

Why programmers use it

  • Speed: a tidy page that works on phones and computers in minutes.
  • Consistency: every button, card and form matches.
  • Shared language: a team, or a student and a teacher, can say "a card in a col" and mean the same thing.

The cost: a large file to load, class names to learn, and pages that look like many other sites until you add your own rules.

An everyday picture, and where it breaks

Flat-pack furniture: the parts are made and labelled for you; you choose them and put them together, and you can paint them afterwards. It breaks because furniture parts fit only one way, while Bootstrap ignores a misspelt label silently (column instead of col just does nothing).

Try it yourself (5 minutes)

  1. In the Bootstrap playground, change btn-primary to btn-danger, then delete the link line and watch the styling vanish.
  2. Copy the card shape from the Reference page into a row, three times.
  3. Add a <style> block after the link with .card { border-color: orange; }, then move it above the link.

Questions students ask

  • Why doesn't my class work? It is not one of Bootstrap's names, or a base class is missing (btn as well as btn-primary).
  • Why doesn't my CSS win? It comes before the link, or the Bootstrap class is a utility (bg-…, mt-…), which always wins.
  • Is Bootstrap the only one? No. Bulma works the same way; Tailwind uses one class per CSS property; daisyUI puts component names on Tailwind; Pico styles plain tags with no classes. The last lesson shows all four.

How it connects

It rebuilds the club page from HTML & CSS (the final challenge) with ready-made parts, so students compare the two directly. The grid is Flexbox inside. Vue, after the DOM course, is the same idea for JavaScript: a framework that does the repetitive work for you.

Cheat sheet: Open to print (A4, with a picture of what each command draws) · Open in Print · Markdown

Open projects

Self-paced briefs students can pick up (after the lesson named on each, where one is named). Students tick their own milestones and claim a badge; the page lights the skills their code uses. Badges stay in the student's browser: ask them to press Show your teacher. Open the projects page

A page for a local business (after bs-components; Bootstrap (its stylesheet and class names: btn, container, alert), Bootstrap components (navbar, card), Bootstrap's grid (row, col))

Make a one-page site for a local business: a café, a bike shop, a vet. A navbar, a big opening line, a card for each thing it offers and a contact form, all from Bootstrap's classes.

Milestones:

  • The navbar and the cards come from Bootstrap's classes.
    1. You do not write the CSS: you add Bootstrap's class names to your tags.
    2. A navbar needs navbar on the outer tag, and each link needs a nav-link class.
    Students can earn this piece (reveal on): <nav class="navbar navbar-expand bg-dark" data-bs-theme="dark">
  • The cards sit in a row on a wide screen and stack on a narrow one.
    1. Bootstrap's grid is a row holding columns. Each column says how wide it is.
    2. col-md-4 means a third of the row from the medium size up, and a full row below that.
    Students can earn this piece (reveal on): <div class="row" id="services">
    <div class="col-md-4">
  • Every box in the form has a label.
    1. Label and box are linked the same way as in plain HTML: for on the label and id on the box.
    2. Bootstrap's form-label and form-control only change how they look.
    Students can earn this piece (reveal on): <label for="name" class="form-label">Your name</label><input id="name" class="form-control">

Navbar, cards and a grid covers everything. To see the cards stack, students widen and narrow the preview (or use Full screen). The labels milestone carries the habit from the HTML forms lesson into Bootstrap's form-label and form-control.

One possible solution
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="bootstrap.min.css">
</head>
<body>
  <nav class="navbar navbar-expand bg-dark" data-bs-theme="dark">
    <div class="container">
      <a class="navbar-brand" href="#">Spoke &amp; Chain</a>
      <ul class="navbar-nav">
        <li class="nav-item"><a class="nav-link" href="#services">Services</a></li>
        <li class="nav-item"><a class="nav-link" href="#contact">Contact</a></li>
      </ul>
    </div>
  </nav>
  <div class="container py-4">
    <h1 class="display-5">Bikes fixed while you wait</h1>
    <p class="lead">A small repair shop on the high street, open six days a week.</p>
    <div class="row" id="services">
      <div class="col-md-4"><div class="card mb-3"><div class="card-body"><h2 class="card-title h5">Flat tyres</h2><p class="card-text">Fixed in 15 minutes.</p></div></div></div>
      <div class="col-md-4"><div class="card mb-3"><div class="card-body"><h2 class="card-title h5">Brakes</h2><p class="card-text">Checked and tuned.</p></div></div></div>
      <div class="col-md-4"><div class="card mb-3"><div class="card-body"><h2 class="card-title h5">Full service</h2><p class="card-text">Your bike, like new.</p></div></div></div>
    </div>
    <form id="contact">
      <div class="mb-3"><label for="name" class="form-label">Your name</label><input id="name" class="form-control"></div>
      <div class="mb-3"><label for="msg" class="form-label">What needs fixing?</label><textarea id="msg" class="form-control"></textarea></div>
      <button class="btn btn-primary">Send</button>
    </form>
  </div>
</body>
</html>
Bootstrap, your way (after bs-yours; Bootstrap (its stylesheet and class names: btn, container, alert), a CSS rule (selector { property: value; }), class selectors (.name))

Take your business page and make it look like yours, not like Bootstrap: your colours, your font, and one component styled your own way.

Milestones:

  • My own rules come after the link to Bootstrap.
    1. When two rules fight, the one that comes later wins.
    2. So your own style tag goes below the link to Bootstrap, not above it.
    Students can earn this piece (reveal on): <link rel="stylesheet" href="bootstrap.min.css">
    <style>
  • There are at least three changes someone could point to.
    1. A colour, a font and a shape (rounded or square corners) are easy changes to spot.
    2. Use the class names Bootstrap already put on the tag as your selector.
    Students can earn this piece (reveal on): body { font-family: Georgia, serif; background: #fbf7ef; }
  • It still works on a narrow screen.
    1. Make the preview narrow and look at it, or use Full screen to resize.
    2. Change colours, fonts and borders, but leave the grid classes alone.

The comparison from Make Bootstrap yours, now on the student's own page. Order matters: rules before the link lose to Bootstrap's. Students who need !important have usually put their rule in the wrong place or picked a weaker selector; that's worth a conversation.

One possible solution
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="bootstrap.min.css">
<style>
  body { font-family: Georgia, serif; background: #fbf7ef; }
  .navbar { background: #2f4f3a !important; }
  .btn-primary { background: #c2570a; border-color: #c2570a; }
  .card { border: 2px solid #2f4f3a; border-radius: 0; }
</style>
</head>
<body>
  <nav class="navbar navbar-expand bg-dark" data-bs-theme="dark">
    <div class="container">
      <a class="navbar-brand" href="#">Spoke &amp; Chain</a>
      <ul class="navbar-nav">
        <li class="nav-item"><a class="nav-link" href="#services">Services</a></li>
        <li class="nav-item"><a class="nav-link" href="#contact">Contact</a></li>
      </ul>
    </div>
  </nav>
  <div class="container py-4">
    <h1 class="display-5">Bikes fixed while you wait</h1>
    <p class="lead">A small repair shop on the high street, open six days a week.</p>
    <div class="row" id="services">
      <div class="col-md-4"><div class="card mb-3"><div class="card-body"><h2 class="card-title h5">Flat tyres</h2><p class="card-text">Fixed in 15 minutes.</p></div></div></div>
      <div class="col-md-4"><div class="card mb-3"><div class="card-body"><h2 class="card-title h5">Brakes</h2><p class="card-text">Checked and tuned.</p></div></div></div>
      <div class="col-md-4"><div class="card mb-3"><div class="card-body"><h2 class="card-title h5">Full service</h2><p class="card-text">Your bike, like new.</p></div></div></div>
    </div>
    <form id="contact">
      <div class="mb-3"><label for="name" class="form-label">Your name</label><input id="name" class="form-control"></div>
      <div class="mb-3"><label for="msg" class="form-label">What needs fixing?</label><textarea id="msg" class="form-control"></textarea></div>
      <button class="btn btn-primary">Send</button>
    </form>
  </div>
</body>
</html>