Master Bootstrap From Scratch

Clear, interactive, and structured Bootstrap lessons designed for beginners and developers.

Bootstrap Grid System

Learn how Bootstrap Grid System helps you create structured and responsive web page layouts.

What is Bootstrap Grid System?

The Bootstrap Grid System is a powerful layout system used to create responsive web pages.

Bootstrap divides a webpage into 12 columns. We can use these columns to arrange text, images, cards, forms and other elements on a webpage.

Simple Explanation:

Imagine a classroom having 12 seats in one row. We can divide these seats between different groups. Bootstrap Grid works in a similar way by dividing a webpage into 12 columns.

How Bootstrap Grid Works

Bootstrap Grid follows a simple structure:

1. Container

The container provides the main area for the webpage content.

2. Row

The row creates a horizontal group for columns.

3. Column

Columns define how much space an element should occupy.

Grid Structure Diagram

Container
↓
Row
↓
Column 1
Column 2
Column 3

Bootstrap 12 Column System

Bootstrap Grid is based on a 12-column system.

A row is divided into 12 equal parts. We can combine these columns to create different layouts.

1
2
3
4
5
6
7
8
9
10
11
12
Important:

Bootstrap uses 12 columns as the base grid.

Basic Grid Syntax

The basic Bootstrap Grid structure contains a container, row and column.

<div class="container">

    <div class="row">

        <div class="col">
            Content
        </div>

    </div>

</div>
Remember:

Container → Row → Column → Content

Equal Columns Using .col

When multiple .col classes are used inside the same row, Bootstrap automatically divides the available width equally.

<div class="row">

    <div class="col">
        Column 1
    </div>

    <div class="col">
        Column 2
    </div>

    <div class="col">
        Column 3
    </div>

</div>
Output:
Column 1
Column 2
Column 3

Using col-6

The col-6 class uses 6 columns out of the available 12 columns.

Calculation:

6 + 6 = 12

<div class="row">

    <div class="col-6">
        Left Content
    </div>

    <div class="col-6">
        Right Content
    </div>

</div>
Output:
col-6
Left Content
col-6
Right Content

Using col-4

We can create three equal columns using col-4.

Calculation:

4 + 4 + 4 = 12

<div class="row">

    <div class="col-4">
        Column 1
    </div>

    <div class="col-4">
        Column 2
    </div>

    <div class="col-4">
        Column 3
    </div>

</div>
Output:
col-4
col-4
col-4

Using col-3

Four equal columns can be created using col-3.

Calculation:

3 + 3 + 3 + 3 = 12

Column 1
Column 2
Column 3
Column 4

Responsive Grid

Bootstrap Grid allows us to change the layout according to different screen sizes.

This helps us create websites that work properly on mobile, tablet and desktop devices.

<div class="col-12 col-md-6 col-lg-4">

    Content

</div>
Meaning:
  • col-12 → Small / Mobile screen
  • col-md-6 → Medium screen
  • col-lg-4 → Large screen
Responsive Example:
Column 1

Responsive Content

Column 2

Responsive Content

Column 3

Responsive Content

Responsive Grid Diagram

The same content can automatically change its layout according to the device size.

Mobile
Column 1
One column per row
Tablet
Column 1
Column 2
Two columns per row
Desktop
Column 1
Column 2
Column 3
Three columns per row

Real-Life Example – CIIT Training Institute

Suppose CIIT Training Institute wants to display three courses on its website:

  • Java Full Stack
  • .NET Full Stack
  • Python Full Stack

We can use col-md-4 to display these three courses side by side on medium and larger screens.

<div class="row">

    <div class="col-md-4">
        Java Full Stack
    </div>

    <div class="col-md-4">
        .NET Full Stack
    </div>

    <div class="col-md-4">
        Python Full Stack
    </div>

</div>
Output:
Java Full Stack

Java + Spring Boot + SQL

.NET Full Stack

C# + ASP.NET Core + SQL

Python Full Stack

Python + Django + SQL

Important Grid Classes

Class Purpose Example
.container Creates the main container <div class="container">
.row Creates a row <div class="row">
.col Creates equal columns <div class="col">
.col-6 Uses 6 columns 6 / 12
.col-4 Uses 4 columns 4 / 12
.col-12 Uses complete row 12 / 12

Common Mistakes

  • Using .col without a .row.
  • Forgetting that Bootstrap uses 12 columns.
  • Using incorrect column combinations.
  • Not using responsive classes for mobile devices.
  • Putting too much content inside a very small column.
Remember:

Container → Row → Column → Content

Summary

In this lesson, we learned that the Bootstrap Grid System is used to create structured and responsive webpage layouts.

We learned how the Bootstrap .container, .row and .col classes work together to create layouts using the 12-column grid system.

We also learned how to use .col-6, .col-4, .col-3 and responsive grid classes to create mobile-friendly layouts.