Skip to content

Introduction to CSS Frameworks | Lecture 45

Introduction to CSS Frameworks

Let’s begin with Lecture 45 of the HTML5 & CSS3 series. Introduction to CSS Frameworks – Bootstrap & Tailwind CSS. This lecture is for absolute beginners; even kids can follow along and understand.

🎯 Objective:

By the end of this lecture, you will:

  • Understand what CSS frameworks are and why they’re useful
  • Know how to use Bootstrap for responsive layouts, buttons, cards, and navigation
  • Be able to build a simple layout using Tailwind CSS
  • Choose when to write custom CSS vs. use a framework
  • Build a responsive card layout or navbar using a CSS framework in minutes!

πŸ›  What Are CSS Frameworks?

CSS frameworks are like pre-built toolkits that give you ready-to-use styles for common elements β€” so you don’t have to write everything from scratch.

Think of it like this:

If building a website was building a house, then CSS frameworks are your pre-made bricks and paint β€” no need to mix cement every time!

🧱 Popular CSS Frameworks

FRAMEWORKBEST FOR
BootstrapFull components (buttons, forms, modals)
Tailwind CSSUtility-first styling (build fast with classes)
FoundationAdvanced layouts and themes
Bulma,Materialize,Semantic UIClean, modern design systems

We’ll focus on Bootstrap and Tailwind CSS today β€” two of the most popular and beginner-friendly options.

🌟 Why Use a CSS Framework?
BENEFITDESCRIPTION
Speed Up DevelopmentReady-made buttons, menus, grids
Responsive DesignBuilt-in mobile-first approach
ConsistencySame look across all browsers
Cross-Browser SupportWorks well on Chrome, Firefox, Safari, etc.
CustomizationChange colors, spacing, fonts easily
Community SupportHuge libraries, plugins, and tutorials
πŸ’‘ Bonus Tip: When to Use a Framework

Use a framework when:

  • You want to build faster
  • You’re making a portfolio , landing page , or dashboard
  • You want consistent design without writing all CSS yourself

Build custom CSS when:

  • You want full creative control
  • You’re learning and practicing layout skills
  • Your project is small and doesn’t need many components
πŸ§ͺ Try This: Build a Responsive Card Layout with Bootstrap

Let’s create a new HTML file that shows off a responsive card layout using Bootstrap .

Step 1: Create a New File

In your VS Code project folder (MyFirstWebsite), create a new file named:

bootstrap-cards.html
Step 2: Add This Code
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>Bootstrap Card Layout</title>
    <!-- Include Bootstrap CDN -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap @5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #f9f9f9;
            padding: 40px;
        }
    </style>
</head>
<body>

    <div class="container">
        <h2 class="text-center mb-4">My Bootstrap Card Layout</h2>

        <div class="row g-4">
            <!-- Card 1 -->
            <div class="col-md-4">
                <div class="card h-100 shadow-sm">
                    <img src="https://picsum.photos/id/1015/300/200 " class="card-img-top" alt="Card image">
                    <div class="card-body">
                        <h5 class="card-title">Card One</h5>
                        <p class="card-text">This is a sample card built using Bootstrap.</p>
                        <a href="#" class="btn btn-primary">Read More</a>
                    </div>
                </div>
            </div>

            <!-- Card 2 -->
            <div class="col-md-4">
                <div class="card h-100 shadow-sm">
                    <img src="https://picsum.photos/id/1016/300/200 " class="card-img-top" alt="Card image">
                    <div class="card-body">
                        <h5 class="card-title">Card Two</h5>
                        <p class="card-text">Bootstrap makes it easy to create beautiful, responsive layouts.</p>
                        <a href="#" class="btn btn-success">Learn More</a>
                    </div>
                </div>
            </div>

            <!-- Card 3 -->
            <div class="col-md-4">
                <div class="card h-100 shadow-sm">
                    <img src="https://picsum.photos/id/1018/300/200 " class="card-img-top" alt="Card image">
                    <div class="card-body">
                        <h5 class="card-title">Card Three</h5>
                        <p class="card-text">Try resizing your browser to see how Bootstrap adapts!</p>
                        <a href="#" class="btn btn-info text-white">Details</a>
                    </div>
                </div>
            </div>
        </div>

        <div class="mt-4 text-center">
            <a href="index.html" class="btn btn-outline-secondary">Back to Home</a>
        </div>
    </div>

</body>
</html>
Step 3: Run with Live Server

Right-click the code β†’ Show All Commands β†’ Launch Live Server

πŸŽ‰ You’ve built a responsive card layout using Bootstrap β€” looks great on desktop and mobile!

Introduction to CSS Frameworks
Introduction to CSS Frameworks
πŸ§ͺ Try This: Build a Simple Button Grid with Tailwind CSS

Now let’s try something similar with Tailwind CSS β€” a utility-first framework where you style directly in HTML.

Step 1: Create a New File

Create a new file named:

tailwind-buttons.html
Step 2: Add This Code
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>Tailwind Buttons</title>
    <!-- Tailwind CSS CDN -->
    <script src="https://cdn.tailwindcss.com "></script>
</head>
<body class="bg-gray-100 min-h-screen p-10">

    <div class="max-w-4xl mx-auto">
        <h2 class="text-3xl font-bold text-center mb-6">Tailwind CSS Button Grid</h2>

        <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
            <!-- Button 1 -->
            <button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-3 px-4 rounded shadow transition duration-300">
                Primary Action
            </button>

            <!-- Button 2 -->
            <button class="bg-green-500 hover:bg-green-700 text-white font-bold py-3 px-4 rounded shadow">
                Success Action
            </button>

            <!-- Button 3 -->
            <button class="bg-red-500 hover:bg-red-700 text-white font-bold py-3 px-4 rounded shadow">
                Danger Action
            </button>
        </div>

        <div class="mt-6 text-center">
            <a href="index.html" class="text-blue-500 underline">Back to Home</a>
        </div>
    </div>

</body>
</html>
Step 3: Run with Live Server

Right-click the code β†’ Show All Commands β†’ Launch Live Server

πŸŽ‰ You’ve built a clean button grid using Tailwind CSS β€” styled entirely in HTML using Tailwind classes!

πŸ’‘ Bonus: Build a Responsive Navbar with Bootstrap

Add a responsive navbar at the top of your Bootstrap layout:

<nav class="navbar navbar-expand-lg bg-primary text-white navbar-dark mb-4">
    <div class="container-fluid">
        <a class="navbar-brand" href="#">MySite</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav ms-auto">
                <li class="nav-item"><a class="nav-link" href="#">Home</a></li>
                <li class="nav-item"><a class="nav-link" href="#">About</a></li>
                <li class="nav-item"><a class="nav-link" href="#">Contact</a></li>
            </ul>
        </div>
    </div>
</nav>

Now your site has a fully responsive navbar with dropdown toggle on smaller screens!

πŸ’‘ Bonus: Tailwind CSS Form

Let’s add a simple form styled with Tailwind:

<h2 class="text-2xl font-semibold mb-4">Subscribe to My Newsletter</h2>

<form class="flex flex-col sm:flex-row gap-2 max-w-xl mx-auto">
    <input type="email" placeholder="you@example.com" class="p-3 border border-gray-300 rounded w-full sm:w-3/4">
    <button class="bg-blue-500 hover:bg-blue-600 text-white font-bold p-3 rounded shadow">
        Subscribe
    </button>
</form>

πŸŽ‰ Now you have a responsive form powered by Tailwind!

πŸ§ͺ Try It Yourself!

  1. Replace Bootstrap images with your own or use object-cover for better fit.
  2. Add a dark mode toggle to your Tailwind layout using JavaScript.
  3. Make one of the Bootstrap cards change color on hover using custom CSS.
  4. Add icons using Font Awesome or Heroicons
  5. Create a pricing section using Bootstrap cards
βœ… Summary of What You Learned Today
CONCEPTDESCRIPTION
CSS FrameworksPre-written CSS tools for faster development
BootstrapComponent-based β€” buttons, cards, navbars, modals
Tailwind CSSUtility-first β€” style directly in HTML
Responsive LayoutsGrids and columns adapt to screen size
Faster DevelopmentNo need to write every style from scratch
Easy CustomizationOverride default styles with your own CSS or theme settings

πŸš€ Next Lecture Preview:

In Lecture 46 , we’ll dive into customizing Bootstrap and Tailwind CSS β€” so you can make them match your brand, theme, or personal style β€” giving you the power of frameworks with the uniqueness of your own design!

Stay Updated

If you found this information useful, don’t forget to bookmark this page and Share.

HTML5 and CSS3 Compleate Series

Najeeb Alam

Najeeb Alam

Technical writer specializes in developer, Blogging and Online Journalism. I have been working in this field for the last 20 years.