🟒 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:

  1. Increase card width
  2. Change gradient colors
  3. 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 πŸ’Ό

You may also like...

2 Responses

  1. April 11, 2026

    […] Next Lesson […]

  2. April 11, 2026

    […] Previous Lesson Next Lesson […]

Leave a Reply

Your email address will not be published. Required fields are marked *