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.

Know someone who'd find this guide helpful? Please share!

Page 6 of 25

Page 6 of 25

logoFALYTOM

Learn technologies like HTML, CSS, JavaScript, React, NodeJS and so much more. Practice your skills with our free games, examples, practice questions & quizzes

    © 2024 Tomilola Group
    • facebook logo
    • twitter logo
    • instagram logo
    • linkedin logo
    • github logo
    • youtube logo