CHAPTER 06
Beginner
Spacing and Sizing Utilities
Updated: May 18, 2026
5 min read
# CHAPTER 6
Spacing and Sizing Utilities
1. Chapter Introduction
Spacing is the most-used category of Bootstrap utilities. Every professional layout uses margin and padding utilities dozens of times per page. Bootstrap's spacing system follows a scale of 0–5 (plusauto) that maps to rem values. Once mastered, you will never write margin: 1rem in custom CSS again.
2. Learning Objectives
-
Apply margin (
m-*) and padding (p-*) utilities.
- Use directional spacing (top, bottom, start, end).
- Use responsive spacing classes.
- Control element width and height.
- Build a card spacing design system.
3. Spacing Scale
text
4. Margin Utilities
html
5. Padding Utilities
html
6. Responsive Spacing
html
7. Width and Height Utilities
html
8. Gap Utilities (Flexbox and Grid)
html
9. Mini Project: Card Spacing Design System
html
10. Common Mistakes
-
Using
m-autoon inline elements:margin: autoonly works on block-level elements with a defined width.
-
Excessive padding on small screens: Use responsive spacing —
py-3 py-md-5— so content doesn't feel cramped on mobile.
11. MCQs
Question 1
What is Bootstrap's spacing value for size 3?
Question 2
What class adds 1.5rem padding on all sides?
Question 3
What class centers a block element horizontally?
Question 4
What class adds margin only on the left?
Question 5
What class makes an element 100% of the viewport height?
Question 6
What py-3 py-md-5 means?
Question 7
What class gives 50% width?
Question 8
What class adds equal gap between flex children?
Question 9
What class adds negative top margin?
Question 10
px-4 applies?
12. Interview Questions
- Q: What spacing scale does Bootstrap 5 use? What real pixel values does it produce?
- Q: How do you center a block element with a fixed width using Bootstrap?