🎨 CSS Lesson 3 - Colors & Backgrounds

Learn how to make your website colorful and attractive.

Changing Text Color

h1{

color:blue;

}

Background Color

body{

background:#f4f7fb;

}

Background Image

body{

background-image:url("background.jpg");

background-size:cover;

background-position:center;

}

Linear Gradient

.hero{

background:linear-gradient(
135deg,
#2563eb,
#7c3aed
);

color:white;

}
💡 Pro Tip: Gradients make modern websites look much more professional.

Color Formats

Format Example
Name red
HEX #2563eb
RGB rgb(37,99,235)
RGBA rgba(37,99,235,.5)
⚠ Common Mistake: Don't use too many different colors. Stick to 2–4 main colors for a professional design.

🧠 Quiz

Which CSS function creates a gradient background?

⬅ Previous Next Lesson ➜

💻 Try It Yourself

Open the HTML Playground and recreate the example above before moving to the next lesson.

Open Playground →