Create a Bootstrap Layout with Equal-width Columns
📖 Scenario: You are building a simple webpage layout using Bootstrap. You want to create a row with three columns that all have the same width, regardless of the content inside them.
🎯 Goal: Build a Bootstrap grid with one row containing three equal-width col columns.
📋 What You'll Learn
Use Bootstrap 5 classes
Create a div with class container as the main wrapper
Inside the container, create a div with class row
Inside the row, create exactly three div elements with class col
Each column should contain some placeholder text like 'Column 1', 'Column 2', and 'Column 3'
💡 Why This Matters
🌍 Real World
Creating equal-width columns is a common task in building responsive web pages, especially for layouts like feature sections, pricing tables, or galleries.
💼 Career
Understanding Bootstrap grid basics is essential for front-end developers and web designers to build clean, responsive layouts quickly.
Progress0 / 4 steps
1
Set up the basic HTML structure with Bootstrap
Create a basic HTML5 document with lang="en". Inside the <head>, add the required meta tags for charset UTF-8 and viewport for responsive design. Also, include the Bootstrap 5 CSS CDN link. In the <body>, add a div with class container to hold your content.
Bootsrap
Hint
Remember to include the Bootstrap CSS link inside the <head> section and add a div with class container inside the body.
2
Add a Bootstrap row inside the container
Inside the existing div with class container, add a div with class row. This will hold the columns.
Bootsrap
Hint
The row class groups columns horizontally. Add a div with class row inside the container.
3
Add three equal-width columns inside the row
Inside the div with class row, add three div elements each with class col. Inside each column, add the text Column 1, Column 2, and Column 3 respectively.
Bootsrap
Hint
Use three div elements with class col inside the row. Add the exact text inside each column.
4
Add a responsive meta tag and a page title
Make sure the <head> section includes a <title> tag with the text Equal-width Columns and the viewport meta tag for responsive design is present.
Bootsrap
Hint
The viewport meta tag helps the page scale on mobile devices. The title appears in the browser tab.
Practice
(1/5)
1. What does using class="col" inside a row in Bootstrap do?
easy
A. Creates columns with fixed pixel widths
B. Creates columns that are always stacked vertically
C. Creates columns that share the row's width equally
D. Creates columns that ignore the row container
Solution
Step 1: Understand Bootstrap's grid system
Bootstrap uses rows and columns to create layouts. The col class means the column will share space equally with other col siblings.
Step 2: Effect of col inside a row
When multiple col classes are inside a row, they automatically divide the row's width evenly.
Final Answer:
Creates columns that share the row's width equally -> Option C
Quick Check:
Equal-width columns = col inside row [OK]
Hint: Remember: col means equal width columns [OK]
Common Mistakes:
Thinking col sets fixed pixel widths
Assuming columns always stack vertically
Believing columns ignore the row container
2. Which of the following is the correct syntax to create three equal-width columns in Bootstrap?
easy
A.
B.
C.
D.
Solution
Step 1: Identify the container for columns
Bootstrap columns must be inside a row to work properly.
Step 2: Check column classes for equal width
Using col without a number creates equal-width columns automatically.
Final Answer:
<div class="row"><div class="col"></div><div class="col"></div><div class="col"></div></div> -> Option A
Quick Check:
Equal-width columns need col inside row [OK]
Hint: Use col inside row for equal widths [OK]
Common Mistakes:
Using col outside a row
Using fixed width classes like col-4 for equal widths
C. Columns should have fixed width classes like col-6
D. No error, code is correct
Solution
Step 1: Check Bootstrap structure rules
Columns (col) must be inside a row to work properly.
Step 2: Identify missing row
The code has container but no row wrapping the columns, so columns won't behave as expected.
Final Answer:
Missing row container around the columns -> Option A
Quick Check:
Columns need row wrapper [OK]
Hint: Always wrap col inside row [OK]
Common Mistakes:
Skipping the row wrapper
Confusing container with row
Thinking fixed width classes are required for equal columns
5. You want to create four equal-width columns that stack vertically on small screens but appear side by side on medium and larger screens. Which Bootstrap classes should you use?
hard
A. col inside a container
B. col-md inside a row
C. col-sm inside a row
D. col-lg inside a container
Solution
Step 1: Understand responsive column classes
Bootstrap uses breakpoint prefixes like col-md to apply column widths starting at medium screen sizes.
Step 2: Choose classes for stacking on small and equal width on medium+
Using col-md inside a row means columns stack vertically on small screens and become equal-width side by side on medium and larger screens.
Final Answer:
col-md inside a row -> Option B
Quick Check:
Use col-md for medium+ equal columns, stack below [OK]
Hint: Use breakpoint classes like col-md for responsive equal columns [OK]
Common Mistakes:
Using col without breakpoint for responsive stacking
Not wrapping columns in a row
Using container instead of row for columns
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.