📖 Scenario: You are building a simple webpage layout using Bootstrap. You want to create a section where a row contains two columns, and inside the first column, you want to nest another row with two smaller columns. This helps organize content clearly and responsively.
🎯 Goal: Create a Bootstrap layout with a main row containing two columns. Inside the first column, nest another row with two columns. Use Bootstrap classes correctly to ensure the layout is responsive and structured.
📋 What You'll Learn
Use a <div> with class container as the main wrapper.
Create a main <div> with class row inside the container.
Inside the main row, create two columns with class col-6 each.
Nest a row inside the first col-6 column.
Inside the nested row, create two columns with class col-6 each.
Add simple text inside each column to identify them (e.g., 'Main Col 1', 'Nested Col 1').
Use semantic HTML and Bootstrap 5 classes.
Ensure the code is valid HTML5 with proper structure and indentation.
💡 Why This Matters
🌍 Real World
Nesting rows and columns is common in real websites to create complex layouts like dashboards, product pages, or forms with multiple sections.
💼 Career
Understanding Bootstrap's grid system and nesting helps front-end developers build responsive and organized web pages efficiently.
Progress0 / 4 steps
1
Create the main container and row
Create a <div> with class container. Inside it, create a <div> with class row. This sets up the main layout structure.
Bootsrap
Hint
Remember, the container holds the row, which holds columns.
2
Add two main columns inside the row
Inside the row, add two <div> elements with class col-6 each. These are the two main columns side by side.
Bootsrap
Hint
Use col-6 to split the row into two equal columns.
3
Nest a row with two columns inside the first main column
Inside the first col-6 column, add a nested <div> with class row. Inside this nested row, add two columns with class col-6 each.
Bootsrap
Hint
Remember to nest the row inside the first column, then add two columns inside that nested row.
4
Add text labels inside all columns
Add the text Main Col 1 inside the first main column, Main Col 2 inside the second main column. Inside the nested columns, add Nested Col 1 and Nested Col 2 respectively.
Bootsrap
Hint
Place the text inside the correct columns to identify them visually.
Practice
(1/5)
1. What is the correct way to nest a row inside a Bootstrap grid layout?
easy
A. Place a .row inside a .col element
B. Place a .col inside a .container directly
C. Place a .container inside a .row
D. Place a .row directly inside another .row
Solution
Step 1: Understand Bootstrap grid nesting rules
Bootstrap requires that a .row must be inside a .container or .col for proper alignment.
Step 2: Identify correct nesting for rows and columns
When nesting, a .row should be placed inside a .col to maintain the grid structure and spacing.
Final Answer:
Place a .row inside a .col element -> Option A
Quick Check:
Nesting rows inside columns = Place a .row inside a .col element [OK]
Hint: Always nest .row inside .col for layout [OK]
Common Mistakes:
Putting .row directly inside another .row
Placing .col directly inside .container without a row
Nesting .container inside .row
2. Which of the following is the correct syntax to nest a row inside a column in Bootstrap?
B. A .row is nested directly inside another .row without a .col
C. The nested .col should be .col-12
D. The outer .row should be .col
Solution
Step 1: Check nesting rules for rows and columns
Bootstrap requires that a .row must be inside a .col when nested.
Step 2: Identify the incorrect nesting
The code nests a .row directly inside another .row without wrapping it in a .col, which breaks the grid structure.
Final Answer:
A .row is nested directly inside another .row without a .col -> Option B
Quick Check:
Row inside row without col = A .row is nested directly inside another .row without a .col [OK]
Hint: Never put .row directly inside another .row [OK]
Common Mistakes:
Nesting rows without columns
Assuming .col is optional inside rows
Confusing container placement
5. You want to create a layout where the left half of the page has two stacked sections, and the right half has a single section. Which Bootstrap structure correctly nests rows and columns to achieve this?