Bitpath

Lesson 1 · Unit 02

Selectors

Pick exactly the elements a rule should style

13 exercisesabout 3 min

What you practise

  • Type, class and id, descendant and child combinators, pseudo-classes, which elements a selector matches

Try a question from this lesson

Pick one

A CSS rule should turn "Tea" and "Sugar" red and leave "Milk" alone. Which selector picks exactly those two?

HTML
<p class="note">Tea</p>
<p>Milk</p>
<div class="note">Sugar</div>
Hint

What do Tea and Sugar share that Milk lacks?

The idea

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Selector, then declarations

A rule is a selector followed by declarations: property: value; pairs in braces. The selector decides which elements receive them.

A bare name matches every element of that type. .note matches every element with class="note". #total matches the one element with id="total".

CSS
p      { color: gray; }
.note  { color: red; }
#total { font-weight: bold; }

11 more exercises in the app

  • 5× type the answer
  • 1× match the pairs
  • 1× true or false
  • 1× fill the blanks
  • 3× multiple choice

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy