Equal-width columns help you divide space evenly on a webpage. This makes your layout look neat and balanced.
Equal-width columns in Bootsrap
<div class="row"> <div class="col">Column 1</div> <div class="col">Column 2</div> <div class="col">Column 3</div> </div>
Use col class inside a row to create equal-width columns.
You can add as many col divs as you want; they will share space equally.
<div class="row"> <div class="col">One</div> <div class="col">Two</div> <div class="col">Three</div> </div>
<div class="row"> <div class="col">Left</div> <div class="col">Right</div> </div>
<div class="row"> <div class="col">A</div> <div class="col">B</div> <div class="col">C</div> <div class="col">D</div> </div>
This example shows three equal-width columns inside a row. Each column has a different background color and centered text. The columns share the space evenly across the container.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Equal-width Columns Example</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" /> </head> <body> <main class="container mt-4"> <h1>Equal-width Columns</h1> <div class="row border p-3"> <div class="col bg-primary text-white text-center p-3">Column 1</div> <div class="col bg-success text-white text-center p-3">Column 2</div> <div class="col bg-warning text-dark text-center p-3">Column 3</div> </div> </main> </body> </html>
Equal-width columns automatically adjust their size to fill the row evenly.
On smaller screens, columns stack vertically by default for better readability.
You can add padding and background colors to columns to make them visually distinct.
Use col inside a row to create equal-width columns easily.
Columns share space evenly without needing to specify widths.
Bootstrap handles responsiveness so columns stack on small screens.
Practice
class="col" inside a row in Bootstrap do?Solution
Step 1: Understand Bootstrap's grid system
Bootstrap uses rows and columns to create layouts. Thecolclass means the column will share space equally with othercolsiblings.Step 2: Effect of
When multiplecolinside arowcolclasses are inside arow, they automatically divide the row's width evenly.Final Answer:
Creates columns that share the row's width equally -> Option CQuick Check:
Equal-width columns =colinsiderow[OK]
col means equal width columns [OK]- Thinking
colsets fixed pixel widths - Assuming columns always stack vertically
- Believing columns ignore the row container
Solution
Step 1: Identify the container for columns
Bootstrap columns must be inside arowto work properly.Step 2: Check column classes for equal width
Usingcolwithout 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 AQuick Check:
Equal-width columns needcolinsiderow[OK]
col inside row for equal widths [OK]- Using
coloutside arow - Using fixed width classes like
col-4for equal widths - Not wrapping columns in a
row
<div class="row"> <div class="col">A</div> <div class="col">B</div> <div class="col">C</div> </div>
Solution
Step 1: Analyze the use of
Eachcolclasses insiderowcolinside arowcreates a column that shares the row's width equally.Step 2: Predict the layout
The three columns labeled A, B, and C will appear side by side with equal widths.Final Answer:
Three columns of equal width side by side labeled A, B, and C -> Option DQuick Check:
Equal-width columns render side by side [OK]
col inside row means side-by-side equal columns [OK]- Thinking columns stack vertically by default
- Assuming columns size by content width
- Confusing
colwith fixed width classes
<div class="container"> <div class="col">One</div> <div class="col">Two</div> </div>
Solution
Step 1: Check Bootstrap structure rules
Columns (col) must be inside arowto work properly.Step 2: Identify missing
The code hasrowcontainerbut norowwrapping the columns, so columns won't behave as expected.Final Answer:
Missingrowcontainer around the columns -> Option AQuick Check:
Columns needrowwrapper [OK]
col inside row [OK]- Skipping the
rowwrapper - Confusing
containerwithrow - Thinking fixed width classes are required for equal columns
Solution
Step 1: Understand responsive column classes
Bootstrap uses breakpoint prefixes likecol-mdto apply column widths starting at medium screen sizes.Step 2: Choose classes for stacking on small and equal width on medium+
Usingcol-mdinside arowmeans columns stack vertically on small screens and become equal-width side by side on medium and larger screens.Final Answer:
col-mdinside arow-> Option BQuick Check:
Usecol-mdfor medium+ equal columns, stack below [OK]
col-md for responsive equal columns [OK]- Using
colwithout breakpoint for responsive stacking - Not wrapping columns in a
row - Using
containerinstead ofrowfor columns
Ready to prove it?
Pass the test and this pattern moves unknown
