๐ข LESSON 3 PRACTICAL
๐ข LESSON 3 PRACTICAL โ Box Model (Spacing Like a Pro)
๐ฏ Goal
You will understand:
- margin (outside space)
- padding (inside space)
- border
- How to control layout cleanly
FIRST: Understand This (CRITICAL)
Every element is a box:
[ margin ]
[ border ]
[ padding ]
[ content ]
๐ Most beginners mess up here โ this is why layouts look bad.
๐งโ๐ป STEP 1: Update Your CSS
Modify your .card:
.card {
background: white;
width: 320px;
padding: 30px; /* inside space */
margin: 100px auto; /* outside space */
border: 3px solid #4facfe;
border-radius: 10px;
text-align: center;
box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}๐ STEP 2: See the Difference
Try changing:
1. Padding
padding: 50px;๐ Content moves away from border
Margin
margin: 200px auto;๐ Card moves away from screen edges
3. Border
border: 5px dashed red;๐ You visually see the box clearly
๐งช STEP 3: Add More Elements
Update your HTML:
<div class="card">
<h1>Welcome to CSS</h1>
<p>This is my first styled card.</p>
<button>Learn More</button>
</div>
<div class="card">
<h1>Second Card</h1>
<p>Practicing spacing is important!</p>
<button>Click Me</button>
</div>๐ฏ STEP 4: Add Space Between Cards
.card {
margin: 50px auto;
}๐ Now cards donโt stick together
๐ฅ STEP 5: Pro Trick (VERY IMPORTANT)
Add this at the top of your CSS:
* {
box-sizing: border-box;
}๐ This makes sizing predictable like a pro
๐ฏ CHALLENGE (DO THIS)
Make your design better:
- Add space between:
- Title and paragraph
- Paragraph and button
๐ Hint:
h1 {
margin-bottom: 10px;
}
p {
margin-bottom: 20px;
}๐ก REAL DEV INSIGHT
padding= comfort inside ๐ฆmargin= space outside ๐border= visual boundary ๐ฒ
๐ Master this = clean UI always

3800z5
md5fqe
pmv90p
iq3fmo
wcv2tg
z8827t
2waq7m
y0z08x
xdecpg
pialwz