Popular Searches
Popular Course Categories
Popular Courses

Bootstrap / Tailwind intro

Bootstrap / Tailwind intro

33 mins CSS3 & Responsive Design

Bootstrap / Tailwind intro in React JS

Course: React JS Training

Topic: Bootstrap / Tailwind intro

Course Link: React JS Training

Demo Link: Register for a Course Demo


1. Introduction: Why CSS Frameworks Matter

By now, in this module, you have written CSS by hand: you have used selectors, the box model, Flexbox, Grid and media queries. That knowledge is essential, but in real projects, writing every button, card, navigation bar and layout from scratch is slow and repetitive. Almost every website needs the same building blocks: a responsive grid, buttons in several sizes, form fields, cards, and a navigation bar that collapses on mobile.

CSS frameworks solve this by giving you a tested, ready-made set of styles and layout tools. Instead of defining what a button looks like, you apply a class name and get a professional-looking button immediately, consistent across your whole site. This is why frameworks dominate professional front-end work, and why job interviews in front-end and React roles often include CSS layout questions alongside framework questions. Frameworks also matter later in this course: when you build React components, you will style them with either Bootstrap classes, Tailwind classes, or plain CSS, so understanding both approaches now makes the React modules much easier.

Two frameworks are the most widely used in the industry today: Bootstrap and Tailwind CSS. This page introduces both, shows how each one works, and helps you understand the philosophy behind each so you can read and write code in either style.

2. What Is a CSS Framework?

A CSS framework is a pre-written library of CSS rules (and sometimes a little JavaScript) that you include in your project. The framework defines standard class names; you apply those class names to your HTML elements, and the framework's rules style them for you.

Think of it like cooking with a ready-made spice mix. You could grind every spice yourself (plain CSS), or you could use a tested mix that gives a reliable result every time (a framework). You still need to know how cooking works — the framework does not replace your understanding of the box model, Flexbox or media queries; it builds on them.

Frameworks generally give you three things:

  • A layout system — a responsive grid or spacing scale so pages line up neatly on every screen size.
  • Reusable component styles — ready-made looks for buttons, cards, forms, tables, navigation bars and alerts.
  • Consistency rules — shared fonts, colours and spacing so the whole site looks like one product instead of separate pages.

It is worth being precise about one point: a framework does not add new power to CSS. Anything a framework produces could be written by hand. What it adds is speed, consistency and fewer mistakes.

3. Key Terms You Will See Everywhere

Before looking at code, learn these words. They appear in every framework's documentation and in almost every tutorial.

  • Class — an HTML attribute value that connects an element to CSS rules. Frameworks are used almost entirely through classes, for example class="btn".
  • Utility class — a small class that does exactly one thing, such as centreing text or adding padding. Tailwind is built almost entirely from utility classes.
  • Component class — a class that styles a complete UI piece, such as a button or card, often combining many CSS properties at once. Bootstrap is built around component classes.
  • Breakpoint — a screen-width boundary where the layout changes, for example "below 768 pixels, stack the columns". You met breakpoints in the media queries sub-module; frameworks give them ready-made names.
  • Container — a wrapper element that centres your content and gives it side margins on large screens.
  • Grid system — the framework's layout mechanism for dividing a row into columns that rearrange themselves on small screens.
  • CDN (Content Delivery Network) — a public web address from which you can load a framework's CSS and JavaScript files directly, without downloading anything.
  • Build step — a process that processes files before the browser sees them. Tailwind traditionally uses a build step to generate only the CSS you actually use; Bootstrap can be used with no build step at all.

4. Two Philosophies: Bootstrap vs Tailwind at a Glance

Bootstrap and Tailwind solve the same problem with opposite strategies. Bootstrap says: "Here is a finished button; use it as it is." Tailwind says: "Here are small building blocks; assemble the button yourself." Neither is wrong — they are different tools for different situations.

AspectBootstrapTailwind CSS
Main ideaReady-made components with fixed looksTiny utility classes you combine yourself
Typical classbtn btn-primarybg-blue-600 px-4 py-2 rounded
Learning curveGentle: memorise component namesSteeper at first: learn the utility naming system
Design freedomLimited unless you override stylesVery high: every visual detail is a class
Speed to first pageVery fast: instant professional lookFast once you know the classes
Custom designNeeds extra CSS to look uniqueCustom designs are the normal workflow
Build stepNot required; a CDN link is enoughCommonly used with a build step for production
JavaScript includedYes, for dropdowns, modals and similar behaviourNo; you bring your own JavaScript
Best suited toAdmin panels, dashboards, quick prototypesCustom-branded sites, design systems, React apps

A helpful way to remember the difference: Bootstrap gives you furniture, Tailwind gives you timber and tools. With Bootstrap you arrange ready pieces; with Tailwind you build each piece to your own measurements.

5. How Bootstrap Works: Structure of a Page

Bootstrap is added to a page with two files: a CSS file for looks and a JavaScript file for interactive behaviour such as dropdown menus and modals. The simplest way for beginners is a CDN link, which means no installation at all.

The starter template

Here is a complete, minimal Bootstrap page. Every part is explained below the code.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>My First Bootstrap Page</title>
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
  <div class="container">
    <h1>Hello, Bootstrap</h1>
    <p>This page already looks tidy, with no CSS written by me.</p>
    <button class="btn btn-primary">Get Started</button>
  </div>

  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

What each part does:

  • The <link> in the head loads Bootstrap's stylesheet. From this moment, all of Bootstrap's class names are available.
  • The <script> before the closing body tag loads Bootstrap's JavaScript bundle, which powers interactive components. If your page has no dropdowns or modals, you can omit it.
  • The viewport <meta> tag is essential. Without it, mobile browsers render the page at desktop width and the responsive classes never get a chance to work.
  • class="container" wraps the content, centreing it and adding comfortable side spacing.
  • class="btn btn-primary" turns a plain <button> into Bootstrap's standard blue button. btn sets the base button look; btn-primary sets the colour theme.
Notice that you wrote zero CSS, yet the page has consistent typography, spacing, a centred layout and a styled button. That is the core promise of a component framework.

6. Bootstrap's Grid System: Rows and Columns

The Bootstrap grid is the framework's most important feature and the one you will use most. It is built on Flexbox, which you already know from the earlier sub-module, so nothing here is new CSS — it is pre-written CSS with friendly names.

The three-layer structure

Every grid layout follows the same nesting pattern:

  1. A container wraps the whole page or section.
  2. Inside it, a row holds one horizontal line of content.
  3. Inside the row, columns divide the space. Bootstrap divides each row into 12 imaginary units, and each column class says how many units that column takes.

Why 12? Because 12 divides evenly by 2, 3, 4 and 6, so half-width, third-width, quarter-width and sixth-width columns are all exact numbers of units.

A simple three-column layout

<div class="container">
  <div class="row">
    <div class="col">Column one</div>
    <div class="col">Column two</div>
    <div class="col">Column three</div>
  </div>
</div>

Three col elements share the row equally, so each gets one third of the width. On a narrow screen, Bootstrap keeps them side by side by default — which may not be what you want.

Making the layout responsive

Column classes can carry a breakpoint prefix that means "apply this width from this screen size upward". The common prefixes are:

Class prefixMeaningApplies from roughly
col-All screen sizes, including the smallest0 pixels and up
col-sm-Small screens and up576 pixels and up
col-md-Medium screens and up768 pixels and up
col-lg-Large screens and up992 pixels and up
col-xl-Extra-large screens and up1200 pixels and up

This is exactly the "mobile first" idea from the media queries sub-module, translated into class names. A very common pattern is: stack on phones, then split into columns on medium screens.

<div class="container">
  <div class="row">
    <div class="col-12 col-md-4">Product photo</div>
    <div class="col-12 col-md-4">Product details</div>
    <div class="col-12 col-md-4">Buy button</div>
  </div>
</div>

Reading the classes out loud: "Take all 12 units (the full width) by default, but from medium screens upward, take 4 units out of 12 (one third)." On a phone the three blocks stack vertically; on a tablet or desktop they sit side by side. You achieved a responsive layout with no media query of your own.

Unequal columns

Columns do not have to be equal. A classic page has a narrow sidebar and a wide content area:

<div class="row">
  <div class="col-12 col-lg-3">Sidebar menu</div>
  <div class="col-12 col-lg-9">Main content</div>
</div>

Three plus nine equals twelve, so the row is exactly filled. On large screens the sidebar takes a quarter of the width; below that, both sections take the full width and stack.

7. Bootstrap Components: Buttons, Cards and Navigation

Beyond the grid, Bootstrap ships styled building blocks called components. You use them by combining the right class names on ordinary HTML elements.

Buttons

The btn class is the base; a theme class sets the colour. Theme names follow a consistent pattern: primary (main blue), secondary (grey), success (green), danger (red), warning (yellow), info (light blue), light and dark.

<button class="btn btn-primary">Save</button>
<button class="btn btn-success">Confirm</button>
<button class="btn btn-danger">Delete</button>
<button class="btn btn-outline-dark">Cancel</button>

The btn-outline-* variants draw a border in the theme colour with a transparent background — useful for secondary actions. Size classes adjust scale: btn-lg for large, btn-sm for small.

Cards

A card is a flexible box with a border, rounded corners and internal padding — the standard way to present a product, article or profile.

<div class="card" style="width: 18rem;">
  <img src="photo.jpg" class="card-img-top" alt="Course cover">
  <div class="card-body">
    <h5 class="card-title">Web Foundations</h5>
    <p class="card-text">Learn HTML, CSS and JavaScript step by step.</p>
    <a href="#" class="btn btn-primary">View course</a>
  </div>
</div>

The structure is worth memorising: card is the outer box, card-img-top makes the image fill the top edge, and card-body adds the padding around the text inside.

Spacing utilities

Bootstrap also includes small utility classes for spacing, using the pattern m or p (margin or padding), a side (t top, b bottom, s start, e end, x both sides, y top and bottom) and a size number from 0 to 5. For example:

<p class="mb-3">Bottom margin, medium size.</p>
<div class="p-4">Padding on all sides, large size.</div>
<h2 class="mt-0">No top margin.</h2>

These utilities matter because even in a component framework, you constantly fine-tune spacing between components, and these classes let you do it without opening a CSS file.

8. How Tailwind Works: The Utility-First Idea

Tailwind CSS takes the opposite approach. It gives you no finished components at all. Instead, it gives you thousands of tiny, single-purpose classes — one for background colour, one for padding, one for rounding corners, one for text size — and you compose them directly in your HTML.

Compare the two philosophies on the same button:

<!-- Bootstrap: one finished component -->
<button class="btn btn-primary">Save</button>

<!-- Tailwind: assembled from utilities -->
<button class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700">
  Save
</button>

Read the Tailwind classes one by one:

  • bg-blue-600 — background colour: shade 600 of blue (Tailwind colours run on a 50 to 950 scale of lightness).
  • text-white — white text.
  • px-4 — horizontal padding (left and right), size 4 on Tailwind's spacing scale.
  • py-2 — vertical padding (top and bottom), size 2.
  • rounded — slightly rounded corners.
  • hover:bg-blue-700 — when hovered, darken the background to blue-700. The hover: prefix applies a class only on hover, replacing a :hover rule you would otherwise write in CSS.

Bootstrap's version is shorter, but it always looks like Bootstrap's button. Tailwind's version is longer, but every visual decision is yours — the exact colour, the exact padding, the exact radius. This is why teams building a unique brand identity often prefer Tailwind: the design lives in the markup, not in someone else's stylesheet.

Using Tailwind on a page

For learning and quick experiments, Tailwind can also be loaded from a CDN, so you can try it with nothing installed:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>My First Tailwind Page</title>
  <script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
  <main class="max-w-2xl mx-auto p-6">
    <h1 class="text-3xl font-bold mb-4">Hello, Tailwind</h1>
    <p class="text-gray-700">Every style on this page is a utility class.</p>
  </main>
</body>
</html>

New classes here: max-w-2xl limits the width of the block, mx-auto centres it with automatic side margins (the same trick as margin: 0 auto), text-3xl sets a large font size, font-bold makes it bold, and text-gray-700 is a mid-grey text colour.

In real production projects, Tailwind is usually installed through a build tool that scans your files and generates a small CSS file containing only the classes you actually used. The CDN approach is intended for learning and prototyping, and that is exactly how you will use it in this course.

9. Tailwind's Naming System: Decoding a Class Name

Tailwind class names look cryptic at first, but they follow a strict grammar. Once you can read the grammar, you can guess the name of any class you need.

The general pattern is:

[state:] [breakpoint:] property-value

The property part

PrefixMeaningExamples
p-, px-, py-, pt-Padding (all, x-axis, y-axis, top)p-4, px-6, py-2, pt-8
m-, mx-, my-, mb-Margin (same side pattern)m-2, mx-auto, mb-4
text-Text colour or sizetext-red-500, text-xl
bg-Background colourbg-slate-100, bg-green-600
border-, rounded-Borders and corner roundingborder, rounded-lg, rounded-full
flex, grid, hiddenDisplay typeflex, grid, hidden
items-, justify-, gap-Flexbox and Grid alignment, spacingitems-center, justify-between, gap-4

The state part

A prefix ending in a colon means "apply this class only in that state". The ones you will use constantly:

  • hover:bg-blue-700 — only when the mouse is over the element.
  • focus:ring-2 — only when the element has keyboard focus.
  • disabled:opacity-50 — only when the element is disabled.

The breakpoint part

A prefix like md: or lg: means "apply this class from this screen width upward". For example, md:flex-row means "use a row direction from medium screens upward". This is Tailwind's equivalent of Bootstrap's col-md- prefixes — the same mobile-first idea, applied to every utility rather than just to columns.

Putting the grammar together: md:hover:bg-blue-700 means "on medium screens and larger, when hovered, use blue-700 as the background". You never needed to write a media query or a :hover rule; the class name expresses both.

10. Worked Example: A Responsive Card Section in Tailwind

Let us build something realistic: a section with three feature cards that stack on phones and sit side by side on larger screens, with hover feedback. First, recall how you would start with plain CSS: a container, a Flexbox or Grid wrapper, a media query to switch between one column and three, plus styling for each card. In Tailwind, all of that is expressed in the markup.

<section class="bg-gray-50 py-12">
  <div class="max-w-5xl mx-auto px-4">
    <h2 class="text-2xl font-bold text-center mb-8">Why choose us</h2>

    <div class="grid grid-cols-1 md:grid-cols-3 gap-6">

      <div class="bg-white rounded-lg shadow p-6 hover:shadow-lg transition">
        <h3 class="text-lg font-semibold mb-2">Learn by building</h3>
        <p class="text-gray-600">
          Every module ends with a project you can show in your portfolio.
        </p>
      </div>

      <div class="bg-white rounded-lg shadow p-6 hover:shadow-lg transition">
        <h3 class="text-lg font-semibold mb-2">Clear fundamentals</h3>
        <p class="text-gray-600">
          Concepts are explained in plain words before the code.
        </p>
      </div>

      <div class="bg-white rounded-lg shadow p-6 hover:shadow-lg transition">
        <h3 class="text-lg font-semibold mb-2">Modern practices</h3>
        <p class="text-gray-600">
          The material follows the way professional teams work today.
        </p>
      </div>

    </div>
  </div>
</section>

Walk through the important classes:

  • grid grid-cols-1 md:grid-cols-3 gap-6 — this one line is the whole responsive layout. It says: "Make this a grid with one column by default; from medium screens upward, three columns; leave a gap between items." On a phone the cards stack; on a tablet they form a row of three.
  • max-w-5xl mx-auto px-4 — a centred content area with a maximum width and side padding, doing the job of Bootstrap's container.
  • bg-white rounded-lg shadow p-6 — the card look: white background, rounded corners, a soft shadow, comfortable padding.
  • hover:shadow-lg transition — on hover the shadow grows, and transition animates the change smoothly instead of snapping. This connects directly to the transitions sub-module: Tailwind's transition class sets up the CSS transition property for you.

Notice what is missing: no <style> block, no separate CSS file, no media query. Everything a browser needs is in the class attributes. The trade-off is equally clear: the class lists are long, and you must learn the vocabulary before the markup reads comfortably.

11. Worked Example: The Same Section in Bootstrap

To make the contrast concrete, here is the same three-card section written with Bootstrap. Compare it line by line with the Tailwind version above.

<section class="py-5 bg-light">
  <div class="container">
    <h2 class="text-center mb-4">Why choose us</h2>

    <div class="row g-4">

      <div class="col-12 col-md-4">
        <div class="card h-100">
          <div class="card-body">
            <h5 class="card-title">Learn by building</h5>
            <p class="card-text">
              Every module ends with a project you can show in your portfolio.
            </p>
          </div>
        </div>
      </div>

      <div class="col-12 col-md-4">
        <div class="card h-100">
          <div class="card-body">
            <h5 class="card-title">Clear fundamentals</h5>
            <p class="card-text">
              Concepts are explained in plain words before the code.
            </p>
          </div>
        </div>
      </div>

      <div class="col-12 col-md-4">
        <div class="card h-100">
          <div class="card-body">
            <h5 class="card-title">Modern practices</h5>
            <p class="card-text">
              The material follows the way professional teams work today.
            </p>
          </div>
        </div>
      </div>

    </div>
  </div>
</section>

Points to observe:

  • row g-4 creates the grid: g-4 is the gutter class that adds spacing between columns (the equivalent of Tailwind's gap-6).
  • col-12 col-md-4 is the responsive rule: full width on phones, one third on medium screens and up. It is the same logic as grid-cols-1 md:grid-cols-3, expressed per column instead of on the parent.
  • card h-100 makes each card fill its column's height, so all three cards stay equal in height — Bootstrap's ready answer to a problem you would solve by hand in plain CSS.
  • The visual result is neat but recognisably "Bootstrap": the same card style appears on millions of sites, because the component's look is fixed.

12. How Frameworks Fit with React

Since this course leads into React, it is worth seeing where frameworks sit in that picture. A React application is built from components, and each component renders HTML-like markup. Framework class names are simply written inside that markup, exactly as in plain HTML.

function SaveButton() {
  return (
    <button className="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700">
      Save
    </button>
  );
}

Two details matter here. First, React uses the attribute className rather than class, because class is a reserved word in JavaScript. Second, the styling approach you learn here transfers directly: many React teams style their components with Tailwind utilities, while others use Bootstrap or plain CSS. Modern React practice also encourages keeping components small and single-purpose — and a framework helps because a small component can carry its complete appearance in its own class list, without hunting through a separate stylesheet.

A practical benefit for your portfolio projects: because frameworks produce consistent results quickly, you spend your time on features and logic rather than re-styling every button, which is exactly what reviewers of beginner projects want to see.

13. Choosing Between Them: A Decision Guide

Neither framework is universally better. Use this guide to reason about which tool fits a given job, and remember that learning both makes you flexible, since real teams use both.

SituationBetter fitWhy
Quick prototype or internal toolBootstrapReady components produce a usable interface in minutes
Dashboard or admin panelBootstrapTables, forms and cards come pre-styled and consistent
Custom-branded public websiteTailwindEvery colour and spacing value is under your control
Design system for a product teamTailwindUtilities compose into your own reusable components
No build tools allowed (single HTML file)BootstrapOne CDN link, no processing step
React or modern JavaScript projectOften TailwindStyles live with each component; no global CSS conflicts
Learning your first frameworkEitherBootstrap teaches components; Tailwind deepens your CSS vocabulary

One more point worth internalising: both frameworks rest on the CSS you already know. Bootstrap's grid is Flexbox; Tailwind's flex, grid, gap and items-center classes are one-to-one names for CSS properties you have already studied. A framework is a vocabulary on top of CSS, not a replacement for it — which is why interviewers can ask a CSS layout question to a candidate who lists a framework on their CV, and expect a real answer.

14. Advanced Bootstrap: Interactive Components

Bootstrap's stylesheet covers looks, but its JavaScript file powers interactive components: navigation bars that collapse on mobile, dropdown menus, modals, tooltips and carousels. These components work through data-* attributes placed in your HTML — Bootstrap's script reads those attributes and wires up the behaviour for you, with no JavaScript written by you.

A responsive navigation bar

The navbar is the most-used interactive component. It shows links in a row on desktop and collapses behind a "hamburger" button on small screens.

<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
  <div class="container">
    <a class="navbar-brand" href="#">JustAcademy</a>
    <button class="navbar-toggler" type="button"
            data-bs-toggle="collapse" data-bs-target="#mainMenu"
            aria-controls="mainMenu" aria-expanded="false"
            aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="mainMenu">
      <ul class="navbar-nav ms-auto">
        <li class="nav-item"><a class="nav-link" href="#">Courses</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>

How to read it:

  • navbar-expand-lg means "show links in a row from large screens upward; collapse them below that".
  • The toggler button carries data-bs-toggle="collapse" and data-bs-target="#mainMenu": "when clicked, show or hide the element with this id".
  • The aria- attributes help screen readers announce the button correctly — a small but real accessibility practice.
  • ms-auto pushes the menu to the right edge (margin-start set to auto).

This whole behaviour — hiding, toggling, animating — would take dozens of lines of CSS and JavaScript by hand. Remember that it only works if Bootstrap's JavaScript file is loaded; a very common beginner bug is a navbar button that does nothing because the script tag was forgotten.

15. Advanced Tailwind: Variants in Real Layouts

In part one you met hover: and md:. Real projects combine several variants on the same element, and once you are comfortable reading them, long class lists become predictable.

A responsive hero section

<section class="flex flex-col items-center text-center
                gap-4 px-4 py-16
                md:flex-row md:text-left md:gap-12 md:px-16">
  <div class="max-w-md">
    <h1 class="text-3xl font-bold md:text-5xl">
      Build websites that work everywhere
    </h1>
    <p class="text-gray-600 mt-3">
      Learn HTML, CSS and JavaScript with clear, practical lessons.
    </p>
    <a href="#courses"
       class="inline-block mt-6 bg-blue-600 text-white px-6 py-3
              rounded-lg font-semibold
              hover:bg-blue-700 focus:ring-4 focus:ring-blue-300">
      Browse courses
    </a>
  </div>
  <img src="hero.jpg" alt="Students working on a project"
       class="w-64 rounded-xl shadow-lg md:w-96">
</section>

Reading the section element's classes: on phones it is a vertical, centre-aligned column; from medium screens upward it becomes a horizontal row with left-aligned text and a wider gap. The heading grows from text-3xl to md:text-5xl. The link has both a hover state and a keyboard focus: ring, which is good practice for accessibility — keyboard users see the same feedback mouse users get.

Group hover for cards

Sometimes you want a child element to react when the parent is hovered. Tailwind's group and group-hover: pair does this:

<a href="#" class="group block p-6 rounded-lg border hover:border-blue-500">
  <h3 class="font-semibold group-hover:text-blue-600">React JS Training</h3>
  <p class="text-gray-600">Hover the card and the title changes colour.</p>
</a>

The parent gets group; any descendant can then use group-hover: to restyle itself when the whole card is hovered. In plain CSS this needs a selector like .card:hover .card-title; Tailwind expresses it inline.

16. Customising Frameworks

Ready-made looks rarely match a brand exactly, so both frameworks provide sanctioned ways to customise — the important skill is doing it through the framework rather than fighting it with random CSS.

Bootstrap: CSS variables

Bootstrap defines its theme colours as CSS custom properties (variables), so you can retheme a page by overriding a handful of variables:

<style>
  :root {
    --bs-primary: #7c3aed;
    --bs-body-font-family: "Segoe UI", sans-serif;
  }
</style>

Placed after Bootstrap's stylesheet, this shifts the primary colour to violet across buttons and links that use the theme, without touching any component class.

Tailwind: the configuration file

Tailwind projects use a configuration file where you extend the default design tokens — colours, fonts, spacing — with your own values:

/** @type {import('tailwindcss').Config} */
module.exports = {
  theme: {
    extend: {
      colors: {
        brand: "#7c3aed"
      }
    }
  }
};

After this, classes like bg-brand and text-brand exist alongside the defaults. The principle is the same in both frameworks: change the design system once, in one place, and every component follows.

17. Common Mistakes and the Correct Way

Beginners hit the same handful of problems with both frameworks. Each mistake below is paired with the fix.

Forgetting the viewport meta tag

Symptom: the page looks fine on a desktop browser but appears tiny and zoomed-out on a phone, and responsive classes seem ignored.

<!-- Wrong: no viewport tag -->
<head>
  <title>My page</title>
</head>

<!-- Correct -->
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>My page</title>
</head>

Nesting a container inside a container

Bootstrap's container already centres and pads content. Nesting another one double-pads the page and makes widths unpredictable. Use one container per page section, and put row directly inside it.

Column classes without a row, or a row without columns

The grid only works with the correct parent-child pairing: container → row → col-*. A col-md-6 outside any row is just a div with a percentage width and no flex behaviour.

Using Bootstrap's interactive components without the JavaScript file

Symptom: the hamburger button renders but does nothing when clicked. Fix: include the Bootstrap bundle script before the closing </body> tag, or drop the script if you truly use no interactive component.

Writing breakpoints in the wrong order in Tailwind

Tailwind breakpoints are "from this width upward", and later CSS wins. The base classes are the mobile styles, so put them first and add larger breakpoints after:

<!-- Confusing: base styles contradict the md rule -->
<div class="md:grid-cols-3 grid-cols-1">

<!-- Correct: mobile first, then larger screens -->
<div class="grid-cols-1 md:grid-cols-3">

Fighting a framework with inline styles

Sprinkling style="margin-top: 37px" over framework markup breaks consistency and cannot be reused. Use the framework's spacing scale (Bootstrap mt-*, Tailwind mt-*) — the exact pixel value matters far less than a consistent rhythm across the site.

Expecting Tailwind's CDN script in production

The CDN build of Tailwind is a large, on-the-fly development tool intended for learning and prototyping. Real projects install Tailwind with a build tool so the shipped CSS contains only the classes actually used. For coursework and practice pages, the CDN is fine — just know the difference.

18. Best Practices for Working with Any Framework

  • Learn the underlying CSS first. You have done this in the earlier sub-modules. Framework classes are names for properties you already understand, so debug by asking "which CSS property does this class set?"
  • Stay consistent within a project. Pick one framework per project. Mixing Bootstrap and Tailwind on the same page gives you two spacing scales, two reset stylesheets and conflicting button styles.
  • Use the spacing scale, not arbitrary values. Layouts look professional when every gap comes from one scale (0.25rem steps in both frameworks), not from one-off pixel values.
  • Keep markup readable. For long Tailwind class lists, one class group per line in your editor, or extract a repeated combination into a component (a real HTML component in a templating setup, or a React component later in this course).
  • Test at real widths. Use your browser's device toolbar to check a phone width, a tablet width and a desktop width. Do not assume a breakpoint behaves the way the name suggests.
  • Respect accessibility. Frameworks style elements but cannot add meaning: keep semantic tags, label form fields, keep visible focus states, and keep colour contrast readable — Tailwind's focus: and Bootstrap's aria- support exist to help with this.
  • Prefer the framework's own extension points (Bootstrap CSS variables, Tailwind config) over overriding styles with increasingly specific selectors.

19. Practical Project: A Responsive Course Landing Page

Build one complete page with Bootstrap's grid and components plus a small amount of custom CSS. It uses everything from this module: container, responsive grid, navbar, cards, buttons and spacing utilities. Follow the steps in order.

Step 1: Set up the page skeleton

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>JustAcademy — Web Foundations</title>
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
  <style>
    .hero { background: #f8f9fa; }
  </style>
</head>
<body>
</body>
</html>

Step 2: Add the navbar

Paste the navbar from the advanced Bootstrap section above inside <body>, changing the brand text and the three link labels to Courses, Syllabus and Contact.

Step 3: Add a hero section with a call to action

<header class="hero py-5 text-center">
  <div class="container">
    <h1 class="display-5 fw-bold">Web Foundations: HTML, CSS &amp; JavaScript</h1>
    <p class="lead mx-auto" style="max-width: 40rem;">
      Learn the building blocks of the web with clear explanations
      and hands-on projects.
    </p>
    <a href="#courses" class="btn btn-primary btn-lg mt-3">See the modules</a>
  </div>
</header>

Step 4: Add a responsive three-card course grid

<section id="courses" class="py-5">
  <div class="container">
    <h2 class="text-center mb-4">What you will learn</h2>
    <div class="row g-4">
      <div class="col-12 col-md-4">
        <div class="card h-100">
          <div class="card-body">
            <h5 class="card-title">HTML5 &amp; Semantic Markup</h5>
            <p class="card-text">Structure pages that browsers and screen readers both understand.</p>
          </div>
        </div>
      </div>
      <div class="col-12 col-md-4">
        <div class="card h-100">
          <div class="card-body">
            <h5 class="card-title">CSS3 &amp; Responsive Design</h5>
            <p class="card-text">Flexbox, Grid, media queries and the frameworks on this page.</p>
          </div>
        </div>
      </div>
      <div class="col-12 col-md-4">
        <div class="card h-100">
          <div class="card-body">
            <h5 class="card-title">JavaScript Fundamentals</h5>
            <p class="card-text">Variables, functions, arrays and objects — the language of the browser.</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>

Step 5: Add a two-column sign-up strip and a footer

<section class="py-5 bg-light">
  <div class="container">
    <div class="row align-items-center g-4">
      <div class="col-12 col-lg-8">
        <h3 class="mb-0">Start with the free foundations module</h3>
      </div>
      <div class="col-12 col-lg-4 text-lg-end">
        <button class="btn btn-success">Enrol now</button>
      </div>
    </div>
  </div>
</section>

<footer class="py-4 text-center text-muted">
  <div class="container">
    &copy; JustAcademy — Web Foundations notes
  </div>
</footer>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>

Step 6: Test it

  1. Open the page in a browser and confirm the navbar links sit in a row.
  2. Open the device toolbar, choose a phone width, and confirm the links collapse behind the hamburger button and the three cards stack vertically.
  3. Drag the width up past the medium breakpoint and confirm the cards form a row of three and the sign-up strip becomes two columns.
  4. Check that the "Enrol now" button aligns right only on large screens (that is what text-lg-end does).

You now have a portfolio-quality landing page built almost entirely from framework classes, with about three lines of your own CSS.

20. Practice Exercises

  1. Rebuild the practical project's card section in Tailwind, matching the layout exactly: one column on phones, three from medium screens, equal gaps and a hover shadow on each card.
  2. Create a Bootstrap row with a sidebar of col-md-3 and content of col-md-9, then change it so the sidebar appears below the content on phones but above it on desktops (hint: order utilities).
  3. Write a Tailwind button that is full width on phones (w-full) and auto width from sm: upward, with a hover colour change and a focus ring.
  4. Take any page you built in the media queries sub-module and convert one section to Bootstrap grid classes; compare the amount of CSS you deleted.
  5. Deliberately remove the viewport meta tag from the project page, view it at a phone width, observe the failure, then restore it. Writing down what you saw fixes the concept permanently.
  6. Using Bootstrap CSS variables, retheme the project page so the primary colour is green, then confirm every btn-primary changed with no HTML edits.

21. Interview Questions and Answers

What is a CSS framework and why do teams use one?

A CSS framework is a pre-written library of CSS rules exposed through standard class names. Teams use one for speed, consistency and fewer bugs: layout, spacing and component styles are already tested, so developers assemble pages instead of re-inventing buttons and grids on every project.

What is the difference between Bootstrap and Tailwind CSS?

Bootstrap is component-oriented: classes like btn btn-primary or card apply a complete, fixed look. Tailwind is utility-first: tiny single-purpose classes like px-4 or bg-blue-600 are combined in the markup to build any look. Bootstrap is faster to a standard result; Tailwind gives full design control and keeps styling decisions visible in the component.

What does "utility-first" mean, and what are its pros and cons?

It means the stylesheet is composed almost entirely of small classes that each do one thing. Pros: no naming fatigue, no dead CSS, styles live next to the markup, and designs are highly customisable. Cons: long class lists reduce markup readability at first, and there is a learning period before the class vocabulary reads fluently.

Explain Bootstrap's 12-column grid.

Each row is a flex container divided into 12 units. Column classes such as col-4 or col-md-6 declare how many units an element occupies. Twelve is chosen because it divides evenly into halves, thirds, quarters and sixths, so common layouts map to whole numbers.

How do breakpoints work in these frameworks, and what is mobile-first about them?

Breakpoints are named screen-width boundaries. In both frameworks, unprefixed classes apply at all widths and prefixed classes (col-md-, md:) apply from that width upward. That structure is mobile-first: you write the phone layout as the base and layer on larger-screen adjustments, which mirrors how CSS media queries should be written.

What is a container in Bootstrap, and how does it differ from a row?

A container is the outer wrapper that centres content and gives it side padding; container-fluid spans the full width. A row sits inside a container and is the flex container that holds columns. The nesting order container → row → column is what makes the grid behave.

How does hover:bg-blue-700 work in Tailwind without writing a :hover rule?

The hover: prefix is a variant. Tailwind generates the underlying CSS selector with the :hover pseudo-class attached, so the utility applies only while the element is hovered. The class name encodes what would otherwise be a separate CSS rule.

Why do React projects often prefer Tailwind or CSS modules over a global stylesheet?

React encourages small, self-contained components, and global stylesheets create naming collisions across components. Utility classes keep each component's appearance inside the component itself, which fits co-locating concerns with the code that uses them — the same principle modern React best practices apply to state and logic.

What is a build step in the context of Tailwind, and why does it matter?

A build step processes source files before they reach the browser. Tailwind's build scans your markup, collects every class you actually used and emits only those rules, so production CSS is small. The CDN script skips this step for convenience but ships a much larger file, which is why it is meant for learning and prototypes.

How would you customise a framework's look for a specific brand?

Through the framework's extension points rather than ad-hoc overrides: Bootstrap exposes theme values as CSS variables that can be redefined after its stylesheet, and Tailwind lets you extend colours, fonts and spacing in its configuration file. Change the design tokens once and every component inherits them.

Can a framework replace knowing Flexbox, Grid and media queries?

No. Framework classes are thin names over those exact CSS mechanisms — Bootstrap's grid is Flexbox, Tailwind's items-center is align-items: center. Interviewers deliberately ask plain CSS layout questions to candidates who list frameworks, because debugging a framework layout requires understanding the CSS beneath it.

What accessibility points matter when using a framework?

Frameworks style the interface but do not add meaning. Keep semantic HTML, label every form control, preserve visible keyboard focus (Tailwind's focus: variants, Bootstrap's focus styles), keep sufficient colour contrast, and add aria- attributes to interactive wrappers like Bootstrap's collapsible navbar button.

22. Quick Revision Checklist

  • I can define a CSS framework and explain speed, consistency and reuse as its benefits.
  • I can state the core difference: Bootstrap ships finished components; Tailwind ships utilities I compose.
  • I can set up a Bootstrap page with the CSS link, optional JS bundle and viewport meta tag.
  • I can build a Bootstrap layout using container → row → col, with responsive prefixes like col-12 col-md-4.
  • I can use Bootstrap components: btn variants, card structure, spacing utilities, and a collapsible navbar.
  • I can decode any Tailwind class using the pattern state : breakpoint : property-value.
  • I can build a responsive Tailwind layout with grid-cols-1 md:grid-cols-3, gaps, padding, colours and hover states.
  • I know the common failure points: missing viewport tag, missing Bootstrap JS, nested containers, columns outside rows, and base classes written after breakpoint classes.
  • I can retheme Bootstrap with CSS variables and extend Tailwind through its config file.
  • I have built a complete responsive landing page with a framework and tested it at phone, tablet and desktop widths.

23. Official Documentation and Further Reading

These links from your course reading list connect this sub-module to the wider React track. The interview-question collection includes CSS layout questions alongside React topics, and the best-practices articles show how styling choices fit into modern component work.

Conclusion

This sub-module closes the CSS3 and Responsive Design module by showing where hand-written CSS meets professional practice. You now know that a framework is a vocabulary built on top of the CSS you already understand: Bootstrap packages that CSS into ready components and a 12-column grid, while Tailwind exposes it as composable utilities that live directly in your markup. You have written real pages in both styles, customised each through its sanctioned extension points, diagnosed the mistakes beginners always make, and built a complete responsive landing page almost entirely from framework classes.

Carry two ideas forward. First, the framework is never a substitute for the fundamentals — every col-md-4 is Flexbox, every md: prefix is a media query, and interviewers know it. Second, both frameworks exist to make you faster at the thing that actually matters: building interfaces. In the next modules you will add JavaScript to these pages and then wrap this markup inside React components, where the styling habits you formed here — small components, consistent spacing scales, styles that live with their markup — become daily working practice.

Learn more in the React JS Training course, or register for a course demo.

Previous Next
whatsapp