0
0
Bootsrapmarkup~10 mins

Gutters and spacing control in Bootsrap - Browser Rendering Trace

Choose your learning style9 modes available
Render Flow - Gutters and spacing control
Load HTML with Bootstrap classes
Parse Bootstrap CSS
Identify gutter and spacing utility classes
Calculate padding and margin values
Apply spacing to grid columns and rows
Render updated layout with gutters and spacing
Bootstrap reads the HTML and CSS classes, calculates spacing from gutter and margin/padding utilities, then applies these to the grid layout before rendering visually.
Render Steps - 3 Steps
Code Added:<div class="container"> <div class="row"> <div class="col">Box 1</div> <div class="col">Box 2</div> <div class="col">Box 3</div> </div> </div>
Before
[Container]
  [Row]
    [Col][Col][Col]
    Boxes with no spacing
After
[Container]
  [Row]
    [Col][Col][Col]
    Boxes touching each other horizontally
Added basic Bootstrap grid with three columns but no gutters, so boxes are side by side with no space between.
🔧 Browser Action:Constructs grid layout with columns, no gutter padding applied.
Code Sample
Three colored boxes arranged in a row with gutters (spacing) of size 3 between columns and rows.
Bootsrap
<div class="container">
  <div class="row g-3">
    <div class="col bg-primary text-white">Box 1</div>
    <div class="col bg-secondary text-white">Box 2</div>
    <div class="col bg-success text-white">Box 3</div>
  </div>
</div>
Render Quiz - 3 Questions
Test your understanding
After applying the g-3 class in step 2, what visual change do you see?
AColumns overlap each other
BNo change, columns still touch
CVisible space between columns and rows
DColumns stack vertically
Common Confusions - 3 Topics
Why do gutters add space inside columns instead of outside?
Bootstrap gutters add padding inside columns and negative margin on the row to keep overall alignment. This means spacing is inside each column, not outside, so backgrounds and borders stay consistent.
💡 Gutters = padding inside columns + negative margin on row to keep layout width.
Why does adding margin (m-3) to columns break the grid alignment?
Margins add space outside elements, which can push columns out of alignment. Gutters use padding inside columns to keep the grid consistent, so use gutters for spacing inside grids.
💡 Use gutters (g-*) for grid spacing, margins (m-*) for spacing outside grid.
Why does removing gutters (g-0) make columns touch but not overlap?
Without gutters, columns have no padding but still have their own width, so they sit side by side touching edges but do not overlap.
💡 No gutters means no space between columns, but columns remain separate blocks.
Property Reference
ClassTypeEffectValueCommon Use
g-0GutterNo spacing between columns and rows0Remove all gutters
g-1GutterSmall spacing between columns and rows0.25remTight spacing
g-3GutterMedium spacing between columns and rows1remDefault comfortable spacing
gx-3Gutter X-axisHorizontal spacing only1remControl horizontal gutters
gy-3Gutter Y-axisVertical spacing only1remControl vertical gutters
m-3MarginAdds margin outside element1remSeparate elements externally
p-3PaddingAdds padding inside element1remSpace inside element boundaries
Concept Snapshot
Bootstrap gutters add padding inside grid columns and negative margin on rows to create consistent spacing. Use g-* classes to control gutter size (e.g., g-3 for 1rem spacing). Use gx-* and gy-* to control horizontal or vertical gutters separately. Margins (m-*) add space outside elements and can break grid alignment. Gutters keep columns aligned and spaced evenly inside the grid container.