Nearby lessons
4 of 19🎯 CSS Selectors
📌 What are CSS Selectors?
CSS Selectors allow you to apply styles to specific HTML elements. They are the foundation of targeting in CSS, enabling you to control how your web content looks and behaves.
Selectors are patterns that match elements in your HTML. CSS uses them to determine which elements a set of style rules should apply to. Mastering selectors is key to writing efficient and clean CSS.
1️⃣ Element Selector
Selects all elements of a specific type such as h1, p, or div.
2️⃣ Grouping Selector
Applies the same styles to multiple selectors by separating them with commas.
3️⃣ Class Selector
Targets all elements with a specific class attribute using a dot (.).
4️⃣ ID Selector
Targets a specific element by its unique ID using a hash (#).
5️⃣ Universal Selector
Selects all elements on the page. Use sparingly, especially on large pages for performance reasons.