×

css · level 1 · unit 4 · 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

A # picks the one element with that id.

An id is a name only one element on the page wears. An is a # followed by the name: #winner picks the element with id="winner".

Use a class for things that repeat, like every price or every tip. Use an id for one-off things, like the main title or the logo.

The # is the same sign that starts a hex code. At the start of a selector it means id. As a value, it starts a colour, like #ffd700.

<h1 id="title">Dog show results</h1>
<ul>
  <li id="winner">Rex</li>
  <li>Biscuit</li>
  <li>Pepper</li>
</ul>
#winner {
  background-color: #ffd700;
  font-weight: bold;
}

Press show my page to see it here.

The id in the HTML has no #. The # only goes in the CSS.