CSS: getting started

Lesson 01 · 10 min

Selectors and the cascade

CSS doesn't "paint a tag". It finds nodes with a rule and argues with other rules.

10 minLesson 1 of 8Practice includedAsk AI on any point

A rule: on the left, who we're looking for; on the right, which properties. .card { color: #111; } means everything with the class card. Specificity: a type is weaker than a class, a class is weaker than an id. Equal strength — whatever comes later in the file wins. !important is almost always a crutch.

Three strengths
AI

You can ask about this rule«A class, not an id, for styling»

  • * means every element — expensive and noisy. Not as a "just in case" reset.
  • Descendant article p — any p inside. Child article > p — only direct ones.
  • Don't mix styles into HTML via style="" unless it's a five-minute prototype.
AI

You can ask about this point«Lesson summary»

Check

Lock it in before you move on

  1. 1. What is usually stronger: a class or a tag name?

  2. 2. Two classes of equal strength. Who wins?

  3. 3. !important is

PracticeSolve the lesson tasksA few short tasks in the editor. Check your code right away and see where it goes wrong.Start practice