HTML & CSS - Mastery / CSS Basics

Selectors, Properties, and Values

πŸ” Selector β€” What You're Targeting

Think of the selector as pointing at an element and saying "I want to style this."

Examples:

  • p β†’ targets every <p> tag

  • .title β†’ targets any element with class="title"

  • #main β†’ targets the single element with id="main"


🎨 Property β€” What Aspect You're Changing

Once something's selected, the property decides which visual trait gets touched.

Examples:

  • color β†’ text color

  • font-size β†’ text size

  • background-color β†’ background fill

  • margin β†’ spacing outside the element


🎯 Value β€” How You Want It Changed

Every property needs a value β€” the actual setting that defines the new look.

Examples:

  • red, blue, #333, rgb(255, 0, 0) β†’ color values

  • 16px, 2em, 100% β†’ size values

  • center, left, bold β†’ alignment/text-style values


🧱 Putting It All Together (Basic Syntax)

selector {
  property: value;
}

Real example:

This will:

  • Target all <h1> elements

  • Make the text teal, 32px, and centered


βœ… Quick Summary

Term

Meaning

Example

Selector

What you're styling

p, .box, #nav

Property

What part you're changing

color, margin

Value

How you want it to look

Blue, 20px