×

html · level 1 · unit 5 · lesson 4

  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

and are name tags for elements.

A class is a group name you can give to many elements, like a team shirt. Write it as an attribute, such as class="note". Lots of elements can share one class.

An id is a name for one element only, like a passport. No two elements on a page may share an id. Use letters and dashes, with no spaces.

Neither changes the look. But a link can jump to an id: href="#rules" jumps to the element with id="rules". Later on, both help you colour and style your page.

<a href="#rules">Jump to the rules</a>
<h2 class="section">Prizes</h2>
<p class="note">Win a cake!</p>
<h2 class="section" id="rules">Rules</h2>
<p class="note">Be kind.</p>

Press show my page to see it here.

The # belongs only in the link. It means look for this id.