← Teacher guide

Make Bootstrap yours

Students put their own CSS after the Bootstrap link, predict that their later rule wins, sort jobs into Bootstrap or hand-built CSS, find a style block in the wrong place, meet Bulma, Tailwind, daisyUI and Pico, and give a Bootstrap club page a look of its own.

Pages with Bootstrap · Ready-made parts · about 55 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

Predict and Run 10 min · Investigate 10 min · Other frameworks 10 min · Modify 10 min · Make 15 min

Before class

Read the unit primer first. The rule students need is the cascade they met in HTML & CSS: when two rules match a tag equally (same kind of selector), the later one wins. So the Bootstrap link goes first and the student's <style> block after it. The planted bug puts the style block first, and Bootstrap's h1 rule then wins.

Two catches you may meet. Bootstrap's spacing and colour utility classes (bg-body-tertiary, mt-3, text-center) are marked important and beat ordinary rules wherever they are, so the run page takes bg-body-tertiary off the navbar before giving it a colour. And a button's hover colour is a separate, stronger rule (.btn:hover), so restyling buttons is fiddly; the tasks avoid it on purpose.

Other frameworks. Bootstrap is one of many. Bulma works the same way with different names (button is-primary). Tailwind, very popular for new projects, has no ready-made parts: each class sets one CSS property (bg-blue-600, px-4), and a build tool writes CSS for just the classes a site uses. Here a browser version of Tailwind (tailwind.js) does that as the page loads; Tailwind's makers say it is for trying things, not real sites. daisyUI adds Bootstrap-style names (btn btn-primary) on top of Tailwind. Pico is classless: it styles plain tags, so a page needs no class names at all. Every one of them is served from this site.

Running the lesson

  1. Predict: ask "which rule comes later?" before anyone answers.
  2. Run: everyone moves the style block above the link, sees it lose, and moves it back.
  3. Investigate: the sort has no single right answer in real life; ask for a reason for each.
  4. Other frameworks: ask what Tailwind would need for a whole card (many classes) and why some people prefer that (everything is in the HTML).
  5. Modify: the Bulma task swaps the whole framework; ask what changed apart from the link (every class name).
  6. Make: ask each student to point to their three rules and say what each changed.

The hard part (on purpose)

When a rule does nothing, students add more rules. Ask "which rule is winning, and why?" and have them check the order before writing anything new.

When students get stuck

What you will seeA question to askThe fix
A rule of their own does nothing.Is the style block after the link?Move the link line to the top.
The navbar colour will not change.Does the navbar have a bg- class?Take the bg- class off; Bootstrap's utility classes beat ordinary rules.
A button changes colour but goes back to blue when the mouse is over it.Which rule styles a button under the mouse?That is .btn:hover; use a Bootstrap colour class instead (btn-success), or leave buttons alone.
Tailwind classes do nothing.Is the tailwind.js script on the page?Add script src="tailwind.js"; without it there is no Tailwind CSS at all.

Answers to the checks

  1. Predict: Bootstrap gives every card a thin grey border. What border will this card have?
    Teal. Both rules match the card, and yours comes after the link, so it wins.
  2. Bootstrap or by hand?: Which way of making the page suits each job better?
    A tidy sign-up page in ten minutes → Bootstrap; Buttons, cards and forms that all match → Bootstrap; A page that works well on a phone without extra work → Bootstrap; A page that does not look like every other site → Your own CSS; Knowing what every rule on your page does → Your own CSS; A tiny page with one heading (no 230 KB file to load) → Your own CSS
    Neither is better everywhere. Bootstrap is quick and consistent; your own CSS is lighter and looks like nobody else's. Many sites use both: Bootstrap for the parts, their own rules for the look.
  3. Spot the bug: The heading should be teal, but it is black. There is no error. Click the line that is in the wrong place.
    line 4
    Bootstrap's rule for h1 comes after yours, so it wins. Move the link line to the top, above the style block.
  4. Bulma: Bulma's button is class="button is-primary". How is it like Bootstrap's btn btn-primary?
    A base class for the shape and a second class for the colour
    Bulma works the same way as Bootstrap with different names: button for the shape, is-primary for the colour.
  5. Tailwind: Tailwind has no ready-made button. Match each of its classes with the one CSS property it sets.
    bg-blue-600 → A. background-color: a blue; text-white → C. color: white; px-4 → E. padding left and right; py-2 → D. padding top and bottom; rounded-lg → B. border-radius
    Tailwind's classes are utilities: each one is a single CSS property. You build the button's look from them, right in the HTML.
  6. Sort them: Sort the frameworks by how they style a button.
    Bootstrap: btn btn-primary → A class for the whole button; Bulma: button is-primary → A class for the whole button; daisyUI: btn btn-primary (on top of Tailwind) → A class for the whole button; Tailwind: bg-blue-600 text-white px-4 py-2 → A class for each property; Pico: just <button> → No classes: plain tags are styled
    daisyUI adds Bootstrap-style names on top of Tailwind; Pico styles plain tags, so the page has no classes at all.
  7. Where this leads: Bootstrap's class names make a page look a certain way. What makes a page do things when people click?
    JavaScript, as in the DOM course
    Frameworks for the look are CSS. To make a page react, you need JavaScript: the DOM course, then Vue, a framework for that.

Solutions

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

Modify › The club's name

<link rel="stylesheet" href="bootstrap.min.css">
<style>
  body { font-family: Georgia, serif; }
  .navbar { background-color: lightblue; }
  .navbar-brand { color: white; font-weight: bold; }
  .card { border: 2px solid teal; }
  .card-title { color: teal; }
</style>

<nav class="navbar navbar-expand">
  <div class="container">
    <a class="navbar-brand" href="#">Chess club</a>
  </div>
</nav>

<div class="container mt-3">
  <div class="row">
    <div class="col">
      <div class="card">
        <div class="card-body">
          <h5 class="card-title">Beginners</h5>
          <p class="card-text">Learn the moves.</p>
          <a class="btn btn-primary" href="#">Join</a>
        </div>
      </div>
    </div>
    <div class="col">
      <div class="card">
        <div class="card-body">
          <h5 class="card-title">Players</h5>
          <p class="card-text">Weekly games.</p>
          <a class="btn btn-primary" href="#">Join</a>
        </div>
      </div>
    </div>
  </div>
</div>

Modify › Square corners

<link rel="stylesheet" href="bootstrap.min.css">
<style>
  body { font-family: Georgia, serif; }
  .navbar { background-color: lightblue; }
  .card { border: 2px solid teal; border-radius: 0; }
  .card-title { color: teal; }
</style>

<nav class="navbar navbar-expand">
  <div class="container">
    <a class="navbar-brand" href="#">Chess club</a>
  </div>
</nav>

<div class="container mt-3">
  <div class="row">
    <div class="col">
      <div class="card">
        <div class="card-body">
          <h5 class="card-title">Beginners</h5>
          <p class="card-text">Learn the moves.</p>
          <a class="btn btn-primary" href="#">Join</a>
        </div>
      </div>
    </div>
    <div class="col">
      <div class="card">
        <div class="card-body">
          <h5 class="card-title">Players</h5>
          <p class="card-text">Weekly games.</p>
          <a class="btn btn-primary" href="#">Join</a>
        </div>
      </div>
    </div>
  </div>
</div>

Modify › Try Bulma

<link rel="stylesheet" href="bulma.min.css">

<div class="section">
  <button class="button is-success is-large">Join</button>
</div>

your own look

<link rel="stylesheet" href="bootstrap.min.css">
<style>
  body { font-family: Verdana, sans-serif; background-color: #fff8e7; }
  .navbar { background-color: darkorange; }
  .navbar-brand { color: white; font-weight: bold; }
  .card { border: 3px solid darkorange; border-radius: 0; }
</style>

<nav class="navbar navbar-expand">
  <div class="container">
    <a class="navbar-brand" href="#">Bake sale club</a>
  </div>
</nav>

<div class="container mt-3">
  <div class="row">
    <div class="col">
      <div class="card">
        <div class="card-body">
          <h5 class="card-title">Bakers</h5>
          <p class="card-text">Bake on Thursday.</p>
          <a class="btn btn-warning" href="#">Join</a>
        </div>
      </div>
    </div>
    <div class="col">
      <div class="card">
        <div class="card-body">
          <h5 class="card-title">Sellers</h5>
          <p class="card-text">Sell on Friday.</p>
          <a class="btn btn-warning" href="#">Join</a>
        </div>
      </div>
    </div>
  </div>
</div>

Stretch and support

Stretch: Rebuild one club card in Tailwind using only utility classes, then in daisyUI with card and card-body. Which took fewer classes? Which would be easier to change across a whole site?

Support: Give students three rules on the board (a font, a navbar colour, a border) and ask them only to place and change them.

Exit ticket

Your rule .card { border-color: teal; } does nothing. What is the first thing to check?

Whether the style block comes after the Bootstrap link; when two rules match equally, the later one wins.

What each step is for

Where it leads

This is the end of the Bootstrap course. The DOM course makes pages react; Vue does for JavaScript what Bootstrap does for CSS, ready-made ways to build an app. Class discussion: a framework saves time and makes sites look alike; which matters more for a club page, and for a company?

Sources