π’ LESSON 2 PRACTICAL
π’ LESSON 2 PRACTICAL β Colors, Backgrounds & Card Design
π― Goal
You will learn:
- Better colors π¨
- Background styling π
- Build your first card UI (real-world component)
π§Ύ STEP 1: Update Your HTML
Replace your index.html with this:
<!DOCTYPE html>
<html>
<head>
<title>CSS Lesson 2</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="card">
<h1>Welcome to CSS</h1>
<p>This is my first styled card.</p>
<button>Learn More</button>
</div>
</body>
</html>π¨ STEP 2: Style Background
Update style.css:
body {
background: linear-gradient(to right, #4facfe, #00f2fe);
font-family: Arial, sans-serif;
}π Now your background becomes a gradient (modern UI style)
π¦ STEP 3: Build a Card (IMPORTANT π₯)
.card {
background: white;
width: 300px;
padding: 20px;
margin: 100px auto;
border-radius: 10px;
text-align: center;
}β¨ STEP 4: Add Shadow (makes it professional)
.card {
box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}π― STEP 5: Style Text
h1 {
color: #333;
}
p {
color: #666;
}π STEP 6: Style Button
button {
background: #4facfe;
color: white;
border: none;
padding: 10px 15px;
border-radius: 5px;
cursor: pointer;
}π STEP 7: Add Hover Effect (feels alive π₯)
button:hover {
background: #00c6ff;
}π― FINAL RESULT
You now have:
- Gradient background π
- Centered card π¦
- Styled button π
- Hover interaction β¨
π This is already real frontend development
π§ͺ CHALLENGE (IMPORTANT)
Improve your design:
- Increase card width
- Change gradient colors
- Add:
.card {
transition: 0.3s;
}
.card:hover {
transform: scale(1.05);
}π This adds animation when hovering
π‘ THINK LIKE A PRO
This βcardβ is used everywhere:
- Blogs
- Dashboards
- Apps
- Portfolios
You just built a reusable UI component πΌ

odtbo3
mx5gw2
4xaa0m
zxpw0t
dlw0ij
iwqc88
Excellent resource that I will be returning to regularly, the depth of coverage combined with the accessible writing style makes it suitable for both beginners and experienced readers.
kr5aq9
This is precisely the kind of detailed and well-researched content that the internet needs more of, it is clear the author cares deeply about providing genuine value to readers.
I found myself nodding along throughout this entire article because every point resonated and felt grounded in real understanding rather than recycled information from other sources.
a6a9xn
A well-researched and thoughtfully presented piece that earns the reader’s trust through its honesty, depth, and the obvious care that has gone into every aspect of its creation.
This post was remarkably insightful, breaking down complex ideas into simple and accessible points so thank you for taking the time to put something this good together.