×

css · level 3 · unit 2 · 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

matches any selector in its list, with less typing.

A space in a selector means inside. .post a picks every link that is a of .post: anywhere inside it, however deep.

Now style links in three places: .post a, .sidebar a, .footer a. With :is() that becomes :is(.post, .sidebar, .footer) a. It matches when the element fits any selector in its brackets.

One catch: :is() takes the specificity of its strongest selector. Put an id in the list and the whole rule weighs as much as an id, even for elements matched by a class.

<article class="post"><a href="https://example.com/1">Read the post</a></article>
<aside class="sidebar"><a href="https://example.com/2">Popular</a></aside>
<footer class="footer"><a href="https://example.com/3">Contact</a></footer>
:is(.post, .sidebar, .footer) a {
  color: #9a3412;
  font-weight: bold;
}

Press show my page to see it here.