Previous Next
Course Home

๐Ÿ“… Week 5 - Day 1: Introduction to Bootstrap & Setup

Monday | Duration: 3 hours

๐ŸŽจ Learn Bootstrap Framework Basics

๐ŸŽฏ Learning Objectives

  • Understand what Bootstrap is and its benefits
  • Learn how to add Bootstrap via CDN
  • Link Bootstrap to HTML projects
  • Test Bootstrap components
  • Understand Bootstrap documentation

๐ŸŒŸ What is Bootstrap?

Bootstrap is the world's most popular front-end framework for building responsive, mobile-first websites.

Why Use Bootstrap?

  • โšก Faster Development: Pre-built components save time
  • ๐Ÿ“ฑ Responsive by Default: Mobile-first approach built-in
  • ๐ŸŽจ Professional Design: Clean, modern aesthetics
  • ๐Ÿ”ง Customizable: Easy to modify and extend
  • ๐ŸŒ Cross-Browser Compatible: Works on all modern browsers
  • ๐Ÿ“š Great Documentation: Extensive resources and examples
  • ๐Ÿ‘ฅ Large Community: Millions of developers worldwide

What Does Bootstrap Include?

  • Grid System: Flexible layout structure (12-column grid)
  • Components: Buttons, cards, navbars, forms, modals, etc.
  • Utilities: Spacing, colors, typography, display classes
  • JavaScript Plugins: Dropdowns, carousels, tooltips, etc.

๐Ÿ“ฆ Installing Bootstrap

Method 1: CDN (Content Delivery Network) - Recommended for Beginners

CDN is the fastest way to get started. Files are hosted online, no download needed!

Bootstrap CSS Link (Add to <head>):

<!-- Bootstrap CSS --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">

Bootstrap JavaScript Bundle (Add before closing </body>):

<!-- Bootstrap JavaScript Bundle with Popper --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>

Method 2: Download Bootstrap Files

  1. Visit getbootstrap.com
  2. Click "Download" button
  3. Extract files to your project folder
  4. Link CSS and JS files locally

Complete HTML Template with Bootstrap

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My First Bootstrap Page</title> <!-- Bootstrap CSS --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <div class="container"> <h1 class="text-center mt-5">Hello, Bootstrap!</h1> <p class="lead text-center">My first Bootstrap webpage</p> <button class="btn btn-primary">Click Me</button> </div> <!-- Bootstrap JavaScript --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> </body> </html>

๐Ÿงช Testing Bootstrap Installation

Test 1: Bootstrap Button

<button class="btn btn-primary">Primary Button</button> <button class="btn btn-success">Success Button</button> <button class="btn btn-danger">Danger Button</button>

Expected Result: You should see three styled buttons with different colors (blue, green, red).

Test 2: Bootstrap Alert

<div class="alert alert-success" role="alert"> Bootstrap is working! โœ… </div>

Test 3: Bootstrap Container

<div class="container"> <h1>Container Example</h1> <p>This content is centered with padding on the sides.</p> </div>

๐Ÿ“š Understanding Bootstrap Classes

Common Bootstrap Class Patterns

Class Purpose Example
container Fixed-width responsive container <div class="container">
container-fluid Full-width container <div class="container-fluid">
btn Button styling <button class="btn btn-primary">
text-center Center text <p class="text-center">
mt-3 Margin top (spacing) <div class="mt-3">
p-4 Padding (all sides) <div class="p-4">

Bootstrap Color Classes

  • btn-primary - Blue (main action)
  • btn-secondary - Gray (secondary action)
  • btn-success - Green (success)
  • btn-danger - Red (danger/delete)
  • btn-warning - Yellow (warning)
  • btn-info - Cyan (information)
  • btn-light - Light gray
  • btn-dark - Dark gray

Live Button Examples:

Outline Button Examples:

๐Ÿ’ป Practice Activity: Create Your First Bootstrap Page

Task: Build a Simple Bootstrap Welcome Page

Create bootstrap-test.html with the following elements:

Complete Example Code

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Bootstrap Test Page</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <!-- Navigation Bar --> <nav class="navbar navbar-expand-lg navbar-dark bg-primary"> <div class="container-fluid"> <a class="navbar-brand" href="#">My First Bootstrap Site</a> </div> </nav> <!-- Main Content --> <div class="container mt-5"> <h1 class="text-center text-primary">Welcome to Bootstrap! ๐ŸŽ‰</h1> <p class="lead text-center"> Building responsive websites just got easier! </p> <!-- Alert Message --> <div class="alert alert-success text-center" role="alert"> โœ… Bootstrap is successfully installed and working! </div> <!-- Buttons --> <div class="text-center mt-4"> <h3>Button Examples</h3> <button class="btn btn-primary">Primary</button> <button class="btn btn-secondary">Secondary</button> <button class="btn btn-success">Success</button> <button class="btn btn-danger">Danger</button> <button class="btn btn-warning">Warning</button> <button class="btn btn-info">Info</button> </div> <!-- Card Example --> <div class="row mt-5"> <div class="col-md-6 mx-auto"> <div class="card"> <div class="card-body"> <h5 class="card-title">What is Bootstrap?</h5> <p class="card-text"> Bootstrap is a powerful front-end framework that helps you build responsive websites quickly and easily. </p> <a href="https://getbootstrap.com" class="btn btn-primary" target="_blank"> Learn More </a> </div> </div> </div> </div> </div> <!-- Footer --> <footer class="bg-dark text-white text-center p-4 mt-5"> <p>ยฉ 2025 My Bootstrap Journey</p> </footer> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> </body> </html>

Steps to Complete

  1. Create a new file: bootstrap-test.html
  2. Copy the code above
  3. Open in browser (Chrome, Firefox, Edge)
  4. Verify all components display correctly
  5. Try resizing the browser window to test responsiveness

๐Ÿ”— Bootstrap Documentation

Essential Resources

How to Use Bootstrap Documentation

  1. Visit the official Bootstrap website
  2. Navigate to "Docs" section
  3. Browse components or search for what you need
  4. Copy example code snippets
  5. Paste into your HTML and customize

โœ๏ธ Practice Exercises

Exercise 1: Button Collection

Create a page with all button variants:

  • All 8 color variations
  • Different sizes (btn-sm, btn-lg)
  • Outline buttons (btn-outline-primary)

Exercise 2: Alert Messages

Create different alert types:

  • Success alert
  • Warning alert
  • Danger alert
  • Info alert

Exercise 3: Text Utilities

Practice text alignment and colors:

  • Center, left, and right aligned text
  • Different text colors (text-primary, text-danger)
  • Text sizes (display-1, lead)

โœ… Today's Deliverable

  • Bootstrap linked to HTML file via CDN
  • Working bootstrap-test.html with navbar
  • At least 6 different colored buttons
  • One alert message displayed
  • One card component working
  • Page tested in browser
  • Screenshot of working Bootstrap page

๐Ÿ› Troubleshooting Common Issues

Issue 1: Bootstrap Not Working

  • โœ… Check internet connection (CDN requires internet)
  • โœ… Verify CSS link is in <head>
  • โœ… Verify JS script is before closing </body>
  • โœ… Check for typos in class names

Issue 2: Buttons Look Plain

  • โœ… Make sure you have both btn and btn-primary classes
  • โœ… Example: <button class="btn btn-primary">

Issue 3: Layout Not Responsive

  • โœ… Check viewport meta tag in <head>
  • โœ… Must have: <meta name="viewport" content="width=device-width, initial-scale=1.0">