📖 Scenario: You are creating a simple webpage layout using Bootstrap. You want to position a content box not at the very left but slightly shifted to the right using Bootstrap's offset columns feature.
🎯 Goal: Build a responsive Bootstrap grid with a single row and one column that is offset by 3 columns on medium screens and larger.
📋 What You'll Learn
Use Bootstrap 5 classes
Create a container with a row
Add one column with class col-md-6
Offset the column by 3 columns on medium screens using offset-md-3
Include some visible content inside the column
💡 Why This Matters
🌍 Real World
Offset columns help position content nicely on a webpage, for example centering a form or creating space on the left side.
💼 Career
Web developers use Bootstrap offsets to build responsive layouts quickly without writing custom CSS.
Progress0 / 4 steps
1
Create the Bootstrap container and row
Write the HTML code to create a <div> with class container and inside it a <div> with class row.
Bootsrap
Hint
Use <div class="container"> and inside it <div class="row">.
2
Add a column with class col-md-6
Inside the row div, add a <div> with class col-md-6 to create a column that takes 6 columns width on medium screens.
Bootsrap
Hint
Use <div class="col-md-6"></div> inside the row.
3
Offset the column by 3 columns on medium screens
Add the class offset-md-3 to the existing column <div> with class col-md-6 to shift it 3 columns to the right on medium screens.
Bootsrap
Hint
Add offset-md-3 to the column's class attribute.
4
Add visible content inside the offset column
Inside the div with classes col-md-6 offset-md-3, add a <p> tag with the text "This column is offset by 3 columns.".
Bootsrap
Hint
Use a <p> tag with the exact text inside the column div.
Practice
(1/5)
1. What does the offset class in Bootstrap do to a column?
easy
A. It hides the column on smaller screens.
B. It changes the column's background color.
C. It makes the column full width.
D. It moves the column to the right by a specified number of grid spaces.
Solution
Step 1: Understand the purpose of offset classes
Offset classes in Bootstrap add empty space to the left of a column, effectively moving it right.
Step 2: Recognize the effect on layout
This shifting right is done by skipping grid columns, creating space before the column starts.
Final Answer:
It moves the column to the right by a specified number of grid spaces. -> Option D
Quick Check:
Offset = move right [OK]
Hint: Offset means shifting column right by empty spaces [OK]
Common Mistakes:
Thinking offset changes color
Assuming offset makes column full width
Confusing offset with hiding columns
2. Which is the correct Bootstrap 3 class to offset a column by 3 grid spaces on medium screens?
easy
A. col-offset-md-3
B. col-md-offset-3
C. offset-md-3
D. md-col-offset-3
Solution
Step 1: Recall Bootstrap 3 offset syntax
Bootstrap 3 uses col-{breakpoint}-offset-{number} for offsets.
Step 2: Match the correct order and spelling
The correct format is col-md-offset-3 for medium screens offset by 3.
Final Answer:
col-md-offset-3 -> Option B
Quick Check:
col-md-offset-3 syntax [OK]
Hint: Remember: col-{breakpoint}-offset-{number} in Bootstrap 3 [OK]
A. The offset class is incorrectly named; it should be col-md-offset-3.
B. The column width col-md-6 is invalid.
C. The row class is missing.
D. The offset number cannot be 3.
Solution
Step 1: Check Bootstrap 3 offset class naming
Bootstrap 3 requires offset classes to be named col-{breakpoint}-offset-{number}.
Step 2: Compare given class with correct syntax
The code uses offset-md-3, which is incorrect for Bootstrap 3.
Final Answer:
The offset class is incorrectly named; it should be col-md-offset-3. -> Option A
Quick Check:
Bootstrap 3 offset = col-md-offset-3 [OK]
Hint: Use full offset class: col-{breakpoint}-offset-{number} [OK]
Common Mistakes:
Using Bootstrap 4+ offset syntax in Bootstrap 3
Missing 'col-' prefix in offset class
Assuming offset number limits
5. You want to create a layout with two columns on medium screens: the first column is 3 grid spaces wide and the second column is 4 grid spaces wide, but the second column should start after skipping 2 grid spaces from the first column. Which Bootstrap 3 classes achieve this?
hard
A. <div class="col-md-3">...</div> <div class="col-md-4 col-md-offset-2">...</div>
B. <div class="col-md-3 col-md-offset-2">...</div> <div class="col-md-4">...</div>
C. <div class="col-md-3">...</div> <div class="col-md-4 offset-md-2">...</div>
D. <div class="col-md-5">...</div> <div class="col-md-4 col-md-offset-2">...</div>
Solution
Step 1: Assign width to first column
The first column should be 3 grid spaces wide, so use col-md-3.
Step 2: Offset second column by 2 grid spaces
The second column is 4 wide and should start after 2 empty spaces, so use col-md-4 col-md-offset-2.