Bird
Raised Fist0
Bootsrapmarkup~5 mins

12-column grid model in Bootsrap

Choose your learning style10 modes available
Introduction

The 12-column grid model helps you organize content on a webpage in neat, equal parts. It makes your page look balanced and easy to read on all devices.

When you want to divide a webpage into sections that line up nicely.
When you need your layout to adjust smoothly on phones, tablets, and computers.
When you want to create columns of different widths that add up to the full page width.
When you want to build responsive designs without writing complex CSS.
When you want to quickly arrange text, images, or buttons side by side.
Syntax
Bootsrap
<div class="container">
  <div class="row">
    <div class="col-4">Content here</div>
    <div class="col-8">More content here</div>
  </div>
</div>

The grid is based on 12 equal parts called columns.

You add up the numbers in col-* classes to 12 or less per row.

Examples
This divides the row into two equal halves.
Bootsrap
<div class="row">
  <div class="col-6">Half width</div>
  <div class="col-6">Half width</div>
</div>
This divides the row into one quarter and three quarters.
Bootsrap
<div class="row">
  <div class="col-3">One quarter</div>
  <div class="col-9">Three quarters</div>
</div>
This divides the row into three equal parts.
Bootsrap
<div class="row">
  <div class="col-4">One third</div>
  <div class="col-4">One third</div>
  <div class="col-4">One third</div>
</div>
Sample Program

This example shows three rows with different column widths using the 12-column grid. Each colored box shows how many columns it takes.

Bootsrap
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>Bootstrap 12-Column Grid Example</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" />
  <style>
    .box {
      background-color: #007bff;
      color: white;
      padding: 1rem;
      text-align: center;
      border-radius: 0.25rem;
      margin-bottom: 1rem;
    }
  </style>
</head>
<body>
  <main class="container mt-4">
    <h1 class="mb-4">12-Column Grid Model</h1>
    <div class="row">
      <div class="col-4 box">4 columns wide</div>
      <div class="col-8 box">8 columns wide</div>
    </div>
    <div class="row">
      <div class="col-3 box">3 columns</div>
      <div class="col-3 box">3 columns</div>
      <div class="col-3 box">3 columns</div>
      <div class="col-3 box">3 columns</div>
    </div>
    <div class="row">
      <div class="col-6 box">6 columns</div>
      <div class="col-6 box">6 columns</div>
    </div>
  </main>
</body>
</html>
OutputSuccess
Important Notes

Always wrap your rows inside a .container or .container-fluid for proper alignment.

Use .row to group columns horizontally.

Columns stack vertically on small screens by default, making your design mobile-friendly.

Summary

The 12-column grid divides the page width into 12 equal parts.

You combine columns by adding their numbers to 12 or less per row.

This system helps create neat, responsive layouts easily.

Practice

(1/5)
1. In Bootstrap's 12-column grid system, how many columns can you combine in a single row without breaking the layout?
easy
A. Only 3 columns maximum
B. Exactly 6 columns only
C. Up to 12 columns combined
D. Any number of columns without limit

Solution

  1. Step 1: Understand the 12-column grid concept

    The grid divides the page width into 12 equal parts, so columns in a row must add up to 12 or less.
  2. Step 2: Apply the rule to column combinations

    You can combine columns as long as their total width does not exceed 12, ensuring the layout fits perfectly.
  3. Final Answer:

    Up to 12 columns combined -> Option C
  4. Quick Check:

    Sum of columns ≤ 12 = Up to 12 columns combined [OK]
Hint: Remember total columns per row must be 12 or less [OK]
Common Mistakes:
  • Thinking you can use more than 12 columns in one row
  • Assuming exactly 6 columns are required
  • Believing any number of columns works
2. Which of the following is the correct Bootstrap class to create a column that spans 4 out of 12 columns?
easy
A. col-6
B. col-12
C. col-8
D. col-4

Solution

  1. Step 1: Identify the class for column width

    Bootstrap uses classes like col-4 to specify a column that spans 4 of the 12 grid columns.
  2. Step 2: Match the class to the required width

    Since we want 4 columns wide, col-4 is the correct class.
  3. Final Answer:

    col-4 -> Option D
  4. Quick Check:

    Class for 4 columns = col-4 [OK]
Hint: Class name matches number of columns (col-4 for 4 columns) [OK]
Common Mistakes:
  • Using col-12 which spans full width
  • Choosing col-8 or col-6 which are wider than 4 columns
  • Confusing col-4 with col-14 (invalid)
3. What will be the layout result of this Bootstrap row?
<div class="row">
  <div class="col-3">A</div>
  <div class="col-6">B</div>
  <div class="col-3">C</div>
</div>
medium
A. Three columns in one row with widths 3, 6, and 3
B. Two rows because columns exceed 12
C. One column spanning full width
D. Columns stacked vertically

Solution

  1. Step 1: Calculate total column width in the row

    Sum of columns: 3 + 6 + 3 = 12, which fits exactly in one row.
  2. Step 2: Understand Bootstrap layout behavior

    Since total is 12, all columns appear side by side in one row with widths proportional to 3, 6, and 3.
  3. Final Answer:

    Three columns in one row with widths 3, 6, and 3 -> Option A
  4. Quick Check:

    Total columns = 12 means one row layout [OK]
Hint: Add column numbers; if 12 or less, same row [OK]
Common Mistakes:
  • Assuming columns exceed 12 and wrap to next row
  • Thinking columns stack vertically by default
  • Believing only one column shows
4. Identify the error in this Bootstrap grid code:
<div class="row">
  <div class="col-5">X</div>
  <div class="col-8">Y</div>
</div>
medium
A. Total columns exceed 12, causing layout break
B. Missing closing tag for row
C. Incorrect class names used
D. No error, layout is correct

Solution

  1. Step 1: Add column widths to check total

    5 + 8 = 13, which is more than 12 allowed per row.
  2. Step 2: Understand Bootstrap grid rules

    When total exceeds 12, columns wrap or break layout, causing unexpected results.
  3. Final Answer:

    Total columns exceed 12, causing layout break -> Option A
  4. Quick Check:

    Sum > 12 means layout error [OK]
Hint: Sum columns; if over 12, layout breaks [OK]
Common Mistakes:
  • Ignoring total column width sum
  • Thinking 5 and 8 fit in one row
  • Assuming class names are wrong
5. You want to create a responsive layout with three columns: first takes 3 columns on small screens and 6 on medium, second takes 6 on small and 3 on medium, third takes 3 on small and 3 on medium. Which Bootstrap classes correctly achieve this?
hard
A. col-md-3 col-sm-6, col-md-6 col-sm-3, col-md-3 col-sm-3
B. col-sm-3 col-md-6, col-sm-6 col-md-3, col-sm-3 col-md-3
C. col-3 col-6, col-6 col-3, col-3 col-3
D. col-sm-6 col-md-3, col-sm-3 col-md-6, col-sm-3 col-md-3

Solution

  1. Step 1: Match small screen classes

    First column: 3 columns on small = col-sm-3, second: 6 columns = col-sm-6, third: 3 columns = col-sm-3.
  2. Step 2: Match medium screen classes

    First column: 6 columns on medium = col-md-6, second: 3 columns = col-md-3, third: 3 columns = col-md-3.
  3. Step 3: Verify option matches all classes

    col-sm-3 col-md-6, col-sm-6 col-md-3, col-sm-3 col-md-3 matches all these class assignments correctly.
  4. Final Answer:

    col-sm-3 col-md-6, col-sm-6 col-md-3, col-sm-3 col-md-3 -> Option B
  5. Quick Check:

    Responsive classes match screen sizes [OK]
Hint: Use col-sm-* for small, col-md-* for medium screens [OK]
Common Mistakes:
  • Mixing up small and medium class prefixes
  • Using col-* without breakpoint for responsiveness
  • Swapping column sizes between breakpoints
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard