Bird
Raised Fist0
Bootsrapmarkup~5 mins

Why a grid system matters in Bootsrap

Choose your learning style10 modes available
Introduction

A grid system helps arrange content neatly on a webpage. It makes your design look organized and easy to follow.

When you want your website to look good on phones, tablets, and computers.
When you need to place text, images, and buttons in a balanced way.
When you want to save time by using ready-made layout rules.
When you want your webpage to adjust automatically to different screen sizes.
When you want to keep your design consistent across pages.
Syntax
Bootsrap
Use Bootstrap classes like .container, .row, and .col to create a grid layout.
Example:
<div class="container">
  <div class="row">
    <div class="col">Content 1</div>
    <div class="col">Content 2</div>
  </div>
</div>
The .container class centers your content and adds padding.
The .row class groups columns horizontally.
The .col class divides the row into equal parts automatically.
Examples
This creates three equal columns side by side inside a container.
Bootsrap
<div class="container">
  <div class="row">
    <div class="col">One</div>
    <div class="col">Two</div>
    <div class="col">Three</div>
  </div>
</div>
This creates two columns each taking half the row's width.
Bootsrap
<div class="container">
  <div class="row">
    <div class="col-6">Half width</div>
    <div class="col-6">Half width</div>
  </div>
</div>
This layout changes on medium and larger screens, dividing the row into 4 and 8 parts out of 12.
Bootsrap
<div class="container">
  <div class="row">
    <div class="col-md-4">One third on medium screens</div>
    <div class="col-md-8">Two thirds on medium screens</div>
  </div>
</div>
Sample Program

This example shows a simple page with a header, a two-column main area that stacks on small screens, and a footer. The grid system makes the content adjust nicely on different devices.

Bootsrap
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Bootstrap Grid Example</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
  <header class="bg-primary text-white text-center p-3">
    <h1>My Grid Layout</h1>
  </header>
  <main class="container mt-4">
    <div class="row">
      <div class="col-12 col-md-6 bg-light border p-3">Left side content</div>
      <div class="col-12 col-md-6 bg-secondary text-white border p-3">Right side content</div>
    </div>
  </main>
  <footer class="bg-dark text-white text-center p-2 mt-4">
    Footer area
  </footer>
</body>
</html>
OutputSuccess
Important Notes

Bootstrap's grid uses 12 columns by default, so column widths add up to 12.

Using responsive classes like col-md-6 helps your layout change on different screen sizes.

Always wrap rows inside a container for proper alignment and padding.

Summary

A grid system helps organize webpage content clearly and neatly.

Bootstrap's grid uses rows and columns to create flexible layouts.

Responsive classes make your design look good on all devices.

Practice

(1/5)
1. Why is a grid system important in Bootstrap for webpage design?
easy
A. It creates pop-up alerts on the page.
B. It helps organize content into neat rows and columns for clarity.
C. It adds animations to buttons.
D. It automatically changes the website's colors.

Solution

  1. Step 1: Understand the purpose of a grid system

    A grid system divides the page into rows and columns to arrange content clearly and consistently.
  2. Step 2: Identify what Bootstrap's grid system does

    Bootstrap uses this system to help developers create organized, flexible layouts that adapt to screen sizes.
  3. Final Answer:

    It helps organize content into neat rows and columns for clarity. -> Option B
  4. Quick Check:

    Grid system = organizes content neatly [OK]
Hint: Grid system = neat rows and columns layout [OK]
Common Mistakes:
  • Thinking grid changes colors automatically
  • Confusing grid with animations or alerts
  • Believing grid adds pop-ups
2. Which of the following is the correct Bootstrap class to create a row in the grid system?
easy
A. .row
B. .container-row
C. .grid-row
D. .column-row

Solution

  1. Step 1: Recall Bootstrap grid structure

    Bootstrap grid uses .row to group columns horizontally.
  2. Step 2: Identify the correct class name

    The official class to create a row is .row, not any other variant.
  3. Final Answer:

    .row -> Option A
  4. Quick Check:

    Row class = .row [OK]
Hint: Rows use class .row always [OK]
Common Mistakes:
  • Using .container-row instead of .row
  • Confusing row with column classes
  • Adding extra words to class names
3. What will be the layout result of this Bootstrap code?
<div class="row">
  <div class="col-6">Left</div>
  <div class="col-6">Right</div>
</div>
medium
A. One column taking full width, the other hidden.
B. Two columns stacked vertically, each full width.
C. Columns overlap each other in the same space.
D. Two columns side by side, each taking half the width.

Solution

  1. Step 1: Understand Bootstrap column classes

    The class col-6 means the column takes 6 out of 12 parts, or half the row width.
  2. Step 2: Analyze the two columns inside the row

    Two col-6 columns inside a row will sit side by side, each occupying half the horizontal space.
  3. Final Answer:

    Two columns side by side, each taking half the width. -> Option D
  4. Quick Check:

    col-6 + col-6 = half + half side by side [OK]
Hint: col-6 means half width side by side [OK]
Common Mistakes:
  • Thinking columns stack vertically by default
  • Assuming columns overlap
  • Believing one column hides the other
4. Identify the error in this Bootstrap grid code:
<div class="row">
  <div class="col-4">One</div>
  <div class="col-5">Two</div>
  <div class="col-5">Three</div>
</div>
medium
A. Column classes must be col-3, col-4, col-5 only.
B. The row class should be col-row instead.
C. The total column widths exceed 12, causing layout issues.
D. Missing container class around the row.

Solution

  1. Step 1: Calculate total column widths

    Columns have widths 4 + 5 + 5 = 14, which is more than the 12 units Bootstrap grid allows per row.
  2. Step 2: Understand Bootstrap grid limits

    Bootstrap rows should have columns totaling 12 or less to fit properly without wrapping or overflow.
  3. Final Answer:

    The total column widths exceed 12, causing layout issues. -> Option C
  4. Quick Check:

    Sum of col widths > 12 breaks layout [OK]
Hint: Sum columns ≤ 12 per row [OK]
Common Mistakes:
  • Ignoring total column width sum
  • Using wrong class names for rows
  • Forgetting container is optional but recommended
5. You want a layout with three columns that stack vertically on small screens but sit side by side on medium and larger screens. Which Bootstrap classes achieve this?
hard
A. col-12 col-md-4 for each column
B. col-4 col-md-12 for each column
C. col-6 col-md-6 for each column
D. col-md-12 col-lg-4 for each column

Solution

  1. Step 1: Understand responsive classes

    col-12 means full width on extra small screens; col-md-4 means one-third width on medium and larger screens.
  2. Step 2: Match requirement to classes

    Using col-12 col-md-4 for each column stacks them vertically on small screens and places them side by side on medium+ screens.
  3. Final Answer:

    col-12 col-md-4 for each column -> Option A
  4. Quick Check:

    Stack small, side by side medium = col-12 col-md-4 [OK]
Hint: Use col-12 for small, col-md-4 for medium+ [OK]
Common Mistakes:
  • Reversing small and medium classes
  • Using same column size for all screens
  • Not stacking columns on small screens
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