CSS Builder Lab · Lesson 1 of 10

The Cascade and Why Styles Win or Lose

Understand how browsers choose between competing rules so CSS feels less mysterious.

Academy Plus Preview available 3 practice exercises 1 homework item

What you will learn

  • Explain the CSS cascade as the browser's way of choosing between competing style rules.
  • Recognize that more than one rule can target the same element.
  • Use simple rule order to explain why one style wins over another.
  • Distinguish between a style existing in a stylesheet and a style actually applying.
  • Prepare for deeper selector and specificity work in the next lesson.

Lesson shape

18 minute lesson with 6 sections, 3 exercises, 3 checkpoint questions, and 1 homework submission.

This track requires the Academy Plus plan.

Lesson preview

Step-by-step structure before you start

Overview

CSS Builder Lab begins

HTML Builder Lab gave your pages structure. CSS Builder Lab starts teaching how those structures become visually deliberate.

The first CSS idea to understand is the cascade. The cascade is the browser's process for deciding which style should apply when more than one CSS rule points at the same element.

This matters because beginner CSS often feels confusing for one reason: the code exists, but a different rule is winning.

In this lesson, keep the idea simple. The browser is not guessing. It is following rules about which CSS should win.

HTML is complete; CSS begins

HTML Builder Lab is complete. CSS Builder Lab now starts by explaining why styles win or lose.

Explain

More than one rule can affect the same element

A single element can match multiple CSS rules.

Example:

p {
color: blue;
}

.notice {
color: green;
}

<p class="notice">Check the cascade.</p>

The paragraph matches p because it is a paragraph. It also matches .notice because it has that class.

Both rules are real. But only one color can show at the same time, so the browser has to decide which one applies.

Both rules can be true

A rule can match an element and still lose to another rule.

example

Rule order in simple conflicts

The simplest cascade conflict happens when two equally strong rules set the same property.

Example:

.notice {
color: blue;
}

.notice {
color: green;
}

The same selector sets color twice. In this simple case, the later rule wins, so the notice becomes green.

This is not the full cascade story. Later lessons will cover specificity and other reasons styles win. For now, rule order is the beginner-safe starting point.

Later can win when strength is equal

When two matching rules are equally strong, the one that appears later can override the earlier one.

Practice

A style can exist but not apply

Seeing CSS in a file does not guarantee the browser will use that value.

A rule might lose because:

another matching rule appears later
another selector is stronger
the property is overwritten
the selector does not actually match the HTML
the stylesheet is not linked correctly

Beginners often say, "My CSS is there, but nothing changed." The cascade gives you a calmer way to debug that feeling. Instead of guessing, ask what rule is matching and what rule is winning.

Exists is not the same as wins

A style can be present in the code while a different style is the one the browser applies.

Explain

Why this comes before specificity

Specificity is the next deeper topic. It explains why some selectors are considered stronger than others.

Before that, you need the base idea:

multiple rules can match
rules can compete
one final value is chosen
the visible page shows the winning value

If you understand that a style can lose, specificity will feel less mysterious. You will not expect every CSS line to automatically show just because it exists.

Specificity builds on the cascade

This lesson teaches the idea of competing rules. The next lesson teaches why some selectors carry more weight.

Wrap up

Common beginner cascade confusion

CSS frustration often comes from a few repeated situations.

Confusion 1: The wrong color is showing. Another rule may be winning.

Confusion 2: The font changed in one place but not another. The selector may not match every element you expected.

Confusion 3: Spacing will not update. A later rule or more specific rule may override it.

Confusion 4: The stylesheet is linked, but a rule does nothing. The selector may not match the HTML.

Your first debugging habit is simple: find the element, find the matching rules, and ask which one wins.

Builder habit

When CSS surprises you, ask what rule is matching and why another rule may be winning.

Homework

Assignments attached to this lesson

Text response

The Cascade and Why Styles Win or Lose: quick check

Write a short beginner explanation of the main idea from The Cascade and Why Styles Win or Lose.

Not started

Open homework