🌐CSS Selector
Also known as Selector, CSS Selectors, Class Selector
The part of a CSS rule that says which parts of the page it styles.
Think of it like
Think of it like calling out in a classroom. Everyone in red, stand up.
Example
Lucy writes .price { color: red; }. Every element on her shop page with the class price turns red at once.
Why it matters
Every style on a page reaches its target through a selector. A wrong one styles too much, or nothing at all.
Definition
Example code
css
nav a {
color: teal;
}Common mistake
Key takeaways
- 1Tag, class or id. p, .name and #name pick in different ways.
- 2Join to narrow. nav a picks only links in the menu.
- 3Classes reuse best. One class can style many elements.