CSS Basic Selectors
Basic Selectors are the foundation of CSS. They help you pick out specific elements on your webpage for styling. Think of selectors as your way of saying, 'Hey CSS, apply these styles here!'
1. Universal Selector
The universal selector *
is like a 'select all' option. It targets every element on the page. Use it when you want to apply the same styles everywhere.
CSScopy
/* Resetting default margins and paddings */
* {
margin: 0;
padding: 0;
}
2. Type Selector
The type selector targets elements by their tag name. If you want to style all paragraphs (<p>
) or headings (<h1>
), this selector is perfect!
CSScopy
/* Style all paragraph tags */
p {
color: #333;
}
Why Start with Basic Selectors?
Mastering basic selectors gives you confidence to create more specific styles later. They are simple, powerful, and essential for beginners.