LESSON 16 OF 100

A class beats a type selector

Use class specificity for a highlighted paragraph.

Official sourceW3C Selectors — specificityReviewed: 2026-08-26
STEP 1 · LEARN

How it works

A class selector has higher specificity than a type selector, so .lead can win even when the p rule appears later.

Correct example
.lead { color: #0f766e; }\np { color: #64748b; }

The lead paragraph remains teal because the class has higher specificity.

Common mistake
p { color: #0f766e; }\np { color: #64748b; }

Specificity is tied, so the final grey rule wins.

STEP 2 · APPLY

Your exercise

Complete the .lead rule with #0f766e and keep the p rule after it.

STEP 3 · BUILD

Write and see the result

index.htmlCSS
Safe resultisolated
The draft stays only in this browser.HTML and CSS allowed · scripts and network blocked
STEP 4 · CHECK

What needs to pass

0%not checked
  • .lead has the requested colour.
  • The general p rule remains grey.
  • The p rule appears after .lead to demonstrate specificity.
Explain the solution logic

The class wins through specificity, not by moving the rule to the end.