×

css · level 1 · unit 4 · lesson 2

  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

A dot picks every element wearing a class.

Back in lesson 2 you met class, a label many elements can share. A is a dot followed by the class name: .sale picks every element with class="sale".

The tag does not matter. A <p>, an <li> and an <h2> can all wear the same class, and one rule styles them all.

An element can wear two classes, with a space between them: class="tip big". It gets the styles of both.

<h1>Shop</h1>
<p class="sale">Teapots: half price!</p>
<p>Mugs: full price.</p>
<p class="sale">Scarves: half price!</p>
.sale {
  color: crimson;
  font-weight: bold;
}

Press show my page to see it here.

The class name in the HTML has no dot. The dot only goes in the CSS.