×

css · level 3 · unit 3 · lesson 3

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

flips a test, so you can style what is missing.

:not() matches elements that fail the selector in its brackets. li:not(.done) picks every item without the done class. Like :is(), it weighs as much as its strongest selector.

Put :has() inside it and you can style what is missing. .card:not(:has(img)) matches cards with no picture. Real data is messy: a product with no photo, a profile with no bio. Plan for it, and the page never looks broken.

<div class="card">
  <img src="cake.svg" alt="Lemon cake">
  <p>Lemon cake</p>
</div>
<div class="card">
  <p>Carrot cake</p>
</div>
.card {
  padding: 12px;
}
.card:not(:has(img)) {
  border-top: 40px solid #f4a261;
}

Press show my page to see it here.