🎯 CSS Lesson 2 - Selectors

Learn how CSS selects HTML elements.

What is a Selector?

A selector tells CSS which HTML element to style.

💡 Tip: Without selectors, CSS doesn't know which element to change.

Element Selector

p{

color:red;

}

This changes every paragraph to red.

Class Selector

.card{

background:blue;

color:white;

}

ID Selector

#title{

font-size:40px;

color:green;

}

Universal Selector

*{

margin:0;

padding:0;

}
âš  Common Mistake: Use IDs only once on a page. Use classes when multiple elements share the same style.

🧠 Quiz

Which selector starts with a dot (.)?

⬅ Previous Next Lesson ➜

💻 Try It Yourself

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

Open Playground →