×

css · level 2 · unit 6 · lesson 1

  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 space between selectors means inside; > means directly inside.

.menu a picks every <a> that sits inside a .menu, at any depth. That link is a of the menu: a child, a grandchild, and so on.

.menu > a is stricter. It only picks an <a> that is a child of .menu, sitting directly inside it with nothing in between.

The space and the > are each a : a symbol between two selectors that says how they are related. Both let you style things by where they sit, with no extra classes.

<div class="menu">
  <a href="https://example.com/home">Home</a>
  <a href="https://example.com/shop">Shop</a>
</div>
<p>Questions? <a href="https://example.com/help">Ask us</a>.</p>
.menu a {
  color: white;
}
.menu {
  padding: 12px;
  background-color: darkslateblue;
}

Press show my page to see it here.

The link in the paragraph is not inside .menu, so it keeps its usual blue.