Bootstrap Columns Lab (Lab 11)

This is Lab 11 in Web Fundamentals (CSCI1450). Before you start Lab 11, be sure you have studied and completed the exercises in the Slideshow for Module 11. Then start with Section A below to set up your project files, and head to Section B to practice Bootstrap columns before building the Puppies website.

The objective of this lab assignment is to become comfortable working with Bootstrap columns and Font Awesome, two important frameworks in web design.

This lab assumes that you have a website template to use as a starting point. If you need a refresher on Bootstrap columns, see Lesson 10.4: Bootstrap Grid System.

Jump to:

The Bootstrap Columns Lab has two parts:

  • Columns Practice (columns.html) โ€” a quick Bootstrap columns exercise so you’re comfortable with the syntax before using it on the real website.
  • Puppies Website (index.html) โ€” a complete web page with all resources provided. This will be something beautiful for your portfolio. You’ll follow the Bootstrap columns layout, but you will make your own design.

In addition, students in CSCI1450 will turn in a screenshot of the completed Bootstrap Grid Worksheet.

Here is a preview of the finished Best in Show Puppies web page, with the column layout for each row:

Preview of the finished Best in Show Puppies website, with arrows labeling the Bootstrap column combination for each row: col-md-12 for the hero, col-md-8 and col-md-4 for the Best in Show row, col-md-4 three times for the puppies, and col-md-3 four times for the footer icons

A. Set Up the Project

Before You Start: Check Your Template You should have already added Bootstrap and Font Awesome to your template while working through the Module 11 slideshow, but it is easy to skip a step. Open your template’s index.html and check that your <head> includes this code:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

And that your page includes this code right before the closing </body> tag:

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js"></script>

If you do not see this code, go back to the Module 11 slideshow and add it before starting this lab.

  1. Duplicate your template folder inside of your websites folder.
  2. Rename the duplicate folder from “template copy” to “puppies”.
  3. Inside your puppies folder, duplicate index.html and rename the copy columns.html. You’ll use index.html to build the Puppies website in the sections below, and columns.html for the Columns Practice exercise.

Now you have the two HTML files you need for this lab: columns.html for the exercise, and index.html for the Best in Show puppies web page.

B. The columns.html Exercise

To build coding fluency with Bootstrap, you’ll work through a quick columns exercise in the columns.html page you created in the previous section. The finished product looks like this:

Bootstrap column exercise answer key showing rows of blue columns in various widths

Now build this exercise in your own files. Your columns.html file already has the Bootstrap stylesheet and script from your template, so there’s nothing to add there.

Step 1. Add the Column CSS

In columns.html, add a <style> tag inside the <head>, and add this CSS inside it. This is what makes the blue boxes you see in the image below: it is not part of the Bootstrap grid itself, simply styling so you can see your columns.

We’re using a <style> tag here instead of adding this to style.css, because columns.html and index.html share that same stylesheet. If this CSS went into style.css, it would also apply to any matching columns on your real Puppies page and mess up your design there. A <style> tag only affects the one HTML file it’s in.

<style>
.col-md-4 p, .col-md-3 p, .col-md-9 p, .col-md-8 p {
   background-color: blue;
   height: 50px;
   width: 100%;
   margin: 5px;
   padding: 12px;
   color: white;
   text-align: center;
}
</style>

Step 2. Build the First Row

Open columns.html and replace the placeholder text in your <main> section with the starter code below. It sets up the first row: three equal columns, using col-md-4 three times.

<div class="container-fluid">
   <div class="row">
      <div class="col-md-4">
         <p>This is a col-md-4</p>
      </div>
      <div class="col-md-4">
         <p>This is a col-md-4</p>
      </div>
      <div class="col-md-4">
         <p>This is a col-md-4</p>
      </div>
   </div>
</div>

Check your browser to make sure it’s working before you continue.

Yikes! My columns aren’t working!

  1. Make sure Bootstrap is properly installed, per the instructions in the Module 11 slideshow.
  2. The columns only work inside of a row, and the row must be inside a container-fluid. Make sure your col-md-* <div> tag is nested inside the row <div> tag, and the row <div> tag is nested inside the container-fluid <div> tag.
  3. Look for typos. For example, <divclass="col-md-4">, <div clas="col-md-4">, or <div class="col-md-4> (missing closing quote) would not work.

Step 3. Build the Second Row

Add the second row: duplicate the <div class="row">...</div> you already have, then change the columns to col-md-3 four times. (If you are having problems, look back at the worksheet or the Bootstrap Columns lesson.)

Step 4. Build the Third Row

Add the third row: duplicate a row again, then change the columns to col-md-3 and col-md-9.

Step 5. Build the Fourth Row

Add the fourth row: duplicate a row again, then change the columns to col-md-8 and col-md-4.

Watch out: a common mistake is wrapping every row in its own container-fluid. You only need one container-fluid for the whole page. Add each new row as its own <div class="row"> inside that same container-fluid, after the closing </div> of the row before it.

Bootstrap column exercise answer key showing rows of blue columns in various widths

Check your work against the screenshot above.

C. Set Up the Puppies Page

  1. Download the Puppies images folder: ๐Ÿ“Ž Download Puppies Images
  2. Create an images folder inside your puppies folder, and add the puppy images to it.

Your puppies folder should now be organized like this:

  • columns.html
  • images
    • puppies-logo.png
    • hero.png
    • corgi.jpg
    • dachshund.jpg
    • pug.jpg
    • white-puppy.jpg
  • index.html
  • style.css

In this section, we’ll add the Best in Show Puppies logo to the <header> tag.

The logo file, puppies-logo.png, is included in the Puppies images folder you downloaded in Section C.

Step 1. Add the Logo Image Tag

In the <header> tag of index.html, replace the existing text with an image tag for the logo. If your template has an <h1> tag in the <header> tag, delete it: the logo image takes its place, and you will add the <h1> tag to the hero in Section E. Remember that the code for an image is <img src="" width="" height="" alt="">

  • For src use: images/puppies-logo.png
  • For width use: 350
  • For height use: 110
  • For alt use: Logo for the Best In Show Puppies website

Step 2. Add the Logo Classes

Add the attribute class="logo img-fluid" to your image tag. Remember that an element can have more than one class, separated by a space. The logo class lets us select the logo separately from the image for styling, and img-fluid keeps it responsive on smaller screens. You can see both classes on this screenshot of the code:

HTML code for the logo img tag inside the header, with width 350, height 110, alt text, and the class attribute set to logo img-fluid

Step 3. Style the Logo

In style.css, add a new selector for .logo, and add the following to center it and give it some breathing room:

  • display: block
  • margin: 10px auto

About that shorthand: margin: 10px auto; is margin shorthand with two values instead of four. The first value (10px) sets the top and bottom margin, and the second value (auto) sets the left and right margin. See Margin, Padding, and White Space for more on shorthand, and Centering Content with CSS for more ways to center things.

You can use the default navigation from your template as-is, with one change.

Step 4. Update the Nav Links

Your template’s About and Contact links point to about.html and contact.html, but this exercise never builds those pages. Change both links to href="#" so they don’t lead to a broken page, and add a comment above the nav explaining why: this website could end up published somewhere a hiring manager sees it, maybe even opening the Chrome Inspector to look at your code, so it’s worth being clear the links are placeholders on purpose, not a mistake.

Code for the nav showing an HTML comment explaining the About and Contact pages are not part of this exercise and won't be published, followed by the nav with Home linking to index.html and About and Contact both using # as placeholders

Check your work against this screenshot:

The Best in Show Puppies logo centered above the teal navigation bar with Home, About, and Contact links

E. Build the Hero Section

For the hero image on this website, we are going to place the hero image inside a Bootstrap column within the <main> tag. Even though you are only making one column, it is still necessary to use Bootstrap so that your margins and padding stay aligned with the rest of the page.

There is a hero image inside of the images folder named hero.png.

Step 1. Start the Bootstrap Column for the Hero

Start the <main> tag with Bootstrap columns. Because the hero image at the top of the page is only one column wide, use col-md-12. If you can’t remember the Bootstrap columns code, see the screenshot below.

Divs showing a container-fluid, row, and col-md-12 for a full-width column.

Step 2. Hero Image with Text

To code a background image, you need both HTML and CSS. For this project, it is easier to make the hero image a background image, so it is easy to place text on top of it.

Place the <div> tag for the hero image in the col-md-12 <div> tag you just created in Step 1. Use “home-hero” as the class name.

Add the text for the hero inside the hero <div> tag. Use an <h1> tag for the website name and an <h2> tag for the breed:

<h1>Best in Show Puppies</h1>
<h2>King Charles Spaniel</h2>

If you need help with the code, see the screenshots below.

F. Add the Best in Show Row

In this section, we’ll add a new row with a heading, some text, and a photo.

Step 1. Close Out the Hero Row

Close out the col-md-12 <div> tag and the row <div> tag you used for the hero image. See the screenshot below.

Code showing the hero div structure inside main, with comments marking which divs to close: the hero div, the col-md-12 column, and the row, while leaving the container-fluid div open

Watch out: do not close the container-fluid <div> tag โ€” it stays open for the rest of the page, and only gets closed at the end of the </main> tag.

Step 2. Open the New Row

Open a new row with two columns: col-md-8 and col-md-4. It’s a good idea to first type out the Bootstrap <div> tags, and then insert the columns. The reason for that is because it is easy to lose track of the closing <div> tags.

Code for a new row with a col-md-8 div for the text and a col-md-4 div for the photo

Step 3. Add the Heading and Text

Inside the col-md-8 <div> tag, add an <h2> tag with the text below, followed by a paragraph with the text that comes after it:

Which One Is Best in Show

Come to this website to see the "Best in Show" puppies! Every puppy on this page is a true champion in our eyes, each with its own breed, personality, and irresistible charm. All puppies are adorable, but which one is the best in show? Send your vote to vote@bestinshowpuppies.com.

Step 4. Add the Photo

There are four square puppy images in your images folder: corgi.jpg, dachshund.jpg, pug.jpg, and white-puppy.jpg. You’ll use dachshund.jpg here, and the other three in the Three Puppies section (Section G).

Inside the col-md-4 <div> tag, add an image tag for the photo. Remember that the code for an image is <img src="" width="" height="" alt="" class="img-fluid puppy">

  • For src use: images/dachshund.jpg
  • For width use: 400
  • For height use: 400
  • For alt use: A black and tan dachshund puppy lying down

The img-fluid and puppy classes are already in the code above. img-fluid is the Bootstrap class you should use on all your images. It resizes the photo to fit the column on every screen size. The puppy class is one that we will use later in this lab to style the puppy photos.

Step 5. Add the Caption

Just like you’ll do for the Three Puppies section, add an <h3> tag with the text “Dachshund” underneath the photo, inside the same column.

Check index.html in a browser to make sure the new row looks right, with the heading and text in the wider column and the photo and its caption in the narrower column.

Step 6. Look at the Row in the Browser

Check index.html in a browser and look closely at your new row, making sure that the two columns stack on mobile.

In addition, you’ll see two problems: the text and the photo aren’t lined up evenly with each other, and the row feels cramped, sitting right up against the sections above and below it. We’ll repair those problems in the next steps.

The Best in Show row before styling, with the heading and text sitting at the top of the column while the dachshund photo fills its full column height, and no spacing above or below the row

Step 7. Center the Columns Vertically

Add align-items-center to the row <div> tag’s class list, for example class="row align-items-center". align-items-center is a Bootstrap class that vertically centers the columns in a row against each other, so the text and photo line up evenly no matter which one is taller. This class goes at the row level, not on the individual columns.

Check index.html in a browser again. The text and photo should now be lined up, though the row will probably still feel cramped.

Step 8. Add Spacing

Add a custom class to the row <div> tag too, for example best-in-show โ€” you can call it whatever you like โ€” so you can target just this row with your own CSS. Your row’s class attribute should now have three classes: class="row align-items-center best-in-show".

In style.css, add a new selector for .best-in-show, and add the following to give the row some breathing room above and below:

  • margin-top: 40px;
  • margin-bottom: 40px;

As you continue with the design, you may want to change the values of the top and bottom margin, depending on your design.

Check index.html in a browser. It should look like this:

The finished Best in Show row, with the heading and text vertically centered against the dachshund photo, and spacing above and below the row

G. Add the Three Puppies

Step 1. Add Three Columns for the Three Puppies

Right after the closing <div> tags from the Best in Show row, insert a new row for the three puppies.

  • Start a new row with <div class=”row”>
  • Create three Bootstrap columns.
  • Make sure all of the <div> tags you opened are closed.

Feeling confused? You already did this in the columns.html exercise โ€” take a look at your code for three columns there.

Step 2. Add the Puppy Images

Use corgi.jpg, pug.jpg, and white-puppy.jpg for the three puppies here (dachshund.jpg was already used in the Best in Show row, Section F).

Remember, the code for an image is:

<img src="" height="400" width="400" alt="" class="img-fluid puppy">

Note that the img-fluid class is already in this code, along with a puppy class. You’ll use the puppy class in Step 4 to style just these three photos, without affecting any other images on the page.

Step 3. Add the Captions

Use an <h3> tag for the text under each puppy, inside the same column as that puppy’s photo โ€” not in a separate row below all three photos.

Here’s why that matters: on a smartphone, the three col-md-4 columns stack on top of each other, in order. If a photo and its caption are in the same column, they stay together when they stack. But if you put all three photos in one row and all three captions in a separate row below them, mobile visitors will see all three photos stacked together, followed by all three captions stacked together โ€” with no way to tell which caption belongs to which puppy.

Save your work and open your file in the browser.

Image of the three puppies in three bootstrap columns

Step 4. Center the Photos and Captions

In style.css, add a new selector for .puppy, and add the following to center the photos once the columns stack on a small screen:

  • display: block
  • margin: 0 auto

Using .puppy instead of a bare img selector means this centering only applies to the three puppy photos โ€” it won’t accidentally center your logo, hero image, or the Best in Show photo too.

Add a new selector for h3 too, and center the text:

  • text-align: center

Since the only <h3> tags on this website are the puppy captions, it’s safe to select h3 directly here, without needing a class.

Step 5. Check Your Work

  • Check your website at a mobile size to make sure the three columns stack on top of each other.
  • Check that the three photos are centered once the columns stack.

Check your indenting. Indenting your code is critical with Bootstrap in order to make sure all of the <div> tags you open are closed. At the end of the </main> tag, make sure all of the <div> tags you opened have been closed with a closing </div> tag.

Now we are going to design our footer with Font Awesome icons in four columns. For your footer, use Font Awesome icons arranged in Bootstrap columns. Here is a screenshot of the finished footer:

Footer for the best in show puppies lab showing font awesome icons in four bootstrap columns.

Step 1. Create Four Bootstrap Columns

Use col-md-3 for the four columns inside your <footer> tag. Add sets of <div> tags:

  • One for the container-fluid class
  • One for a row for the footer icons
  • Four for the four columns.

Be sure to close all of the <div> tags you have opened.

Step 2. Add the Icons and Text to the Divs

Use the Font Awesome 4 Icons tool to browse common icons. Each one has a ready-to-copy <i> tag, already including aria-hidden="true", so you can paste it straight into your code. For icons outside that curated list, see the official Font Awesome 4.7.0 icon list.

Step 3. Style the Icons in the Footer

Select and style the icons with CSS using the fa class. Because you may have other icons elsewhere on the website, it is a good idea to select footer .fa, so you are only selecting the icons inside the <footer> tag.

Since each icon is wrapped in an <a> tag, the browser’s default underline may show up beneath it. Remove it with:

footer a {
   text-decoration: none;
}

Check your <footer> tag and compare it to the screenshot above.

Step 4. Make the Footer Full-Width (Optional)

This step is optional โ€” it looks nicer, but it’s an extra technique on top of an already full lab, so skip it if you’re short on time. Without it, your <footer> tag’s icons will simply spread out edge to edge on wide screens instead of staying centered at a readable width. It looks more professional to have the <footer> tag be the same width as your content, as shown in the screenshot below:

The finished footer, with the icon row centered at a readable width inside the full-width dark footer background

It is also important to keep the <footer> tag itself full-width for its background color. If you add a max-width directly to your <footer> tag’s selector, the background color will only fill part of the page instead of stretching edge to edge.

To fix this:

  • Insert a <div> tag inside your <footer> tag, around the container-fluid <div> tag and everything inside it. A good name for the class is “inner-footer”, i.e. <div class="inner-footer">, but you can name the class anything you would like.
  • Apply the same max-width: 1000px; and margin: 0 auto; trick you used for your <main> tag to this new wrapper <div> tag, not to the <footer> tag itself.

With this approach, the <footer> tag itself stays full width, so its background color fills the entire page. The new wrapper <div> tag inside it keeps your icons centered at a readable 1000px width.

I. Design Your Website

Now that you have the pieces in place, make the website your own by changing the CSS. At a minimum, you must choose your own fonts, colors, and background colors throughout the site. See the Websites Made by Students section below for examples from other students who have taken this course.

Optional: Want to design your own logo instead of using the provided puppies-logo.png? Go for it — you’re welcome to create your own, including using an AI image tool to generate it. As a reminder, AI is only permitted for content and images, never for coding or for reading and interpreting these instructions. See the AI Usage Policy on the Class Policies page for the full details.

Step 1. Choose Your Fonts

Choose fonts for your website that fit the topic. You may need to return to our lesson on Font Families and Google Fonts to find different fonts. For headings, you can use a more creative font. For regular text, the font must be easy to read, not bold, and not capitalized.

Step 2. Choose Your Colors

Make an active choice about the colors you want to use on your website. If you need help choosing, try the Simple Hexadecimal Color Picker or CSS Color Name Picker. Try the Color Picker: Choose from Image tool to pick colors directly from the logo or one of the puppy photos, so your website matches.

Step 3. Apply CSS Properties

At a minimum, you must do some design work on the header, navigation, footer, Best in Show row, and the headings under each puppy.

How much design work is enough? You need to actively choose colors and fonts for your website, and style your header and navigation to match. After that, use your judgment about what CSS to add to make your website look professional. Design can be a bit subjective in grading, so I am looking for a real effort to apply the CSS we have learned in class. Feel free to reach out to me if you need help with the design.

Remember that you already added a .puppy class to the puppy photos earlier in this lab — you can select it in style.css to style all of the puppy photos at once.

Here are some CSS properties you may want to use:

  • background-color
  • color (text-color)
  • font-size
  • line-height, to add some visual weight to a short block of text without making the words themselves look oversized
  • borders and border-radius (border, border-bottom, border-top, etc.), try the Border Generator
  • box-shadow, try the Box-Shadow Generator
  • text-shadow, try the Text-Shadow Generator
  • padding and margin, to manage spacing
  • text-align (center, left, right)

Step 4. Footer Copyright

Be sure to use your own copyright on the website. The design is yours. If you would like to add some explanation to the footer, you could add this above your copyright:

I designed this web page for my Web Fundamentals course at Saint Paul College. This page includes use of Bootstrap columns and Font Awesome icons. The puppy photos for this lab are from Pixabay.com.

Browse Student Examples

These examples were submitted before the logo and the Best in Show row were added to this lab, so you won’t see those in them. Everything else is still a good reference for layout and design ideas.

Review the Grading Checklist

Here is a checklist of what I will be looking for when grading the website. Submit your entire websites folder. I am also grading the columns.html file in your puppies folder this week.


Now you know how to work with Bootstrap columns! In the meantime you made a solid item for your portfolio. We’ll do a lot more work with Bootstrap columns in the upcoming labs. In the next lab, Lab 12, we’ll get more practice with Bootstrap columns, make a cool JavaScript photo gallery, and learn about cropping, resizing, and optimizing images.

Screenshot of the Best In Show PUPPIES website

Need Help?

Using AI for coding is not allowed in this course, so if you get stuck simply Make an Appointment for office hours. In addition, if you run into a bug as you are working, you may email your websites folder to me at susan.metoxen@saintpaul.edu.

Browse All Lessons

CSS Design Tools