Why can't I just apply a large amount of selectors to CSS script?

Viewed 40

I just began learning HTML/CSS a few day ago and I was wondering why a lot of my code that I have been writing recently isn't working properly.

Why can't I simply use many selectors in order to apply all of my desired declarations?

header nav ul {
  list-style: none;
  text-decoration: none;
  color: black;
}
<header>
  <nav>
    <ul>
      <li><a href="#">Home</a></li>
      <li><a href="#">About</a></li>
      <li><a href="#">Blog</a></li>
      <li><a href="#">Contact</a></li>
    </ul>
  </nav>
</header>

1 Answers

As zer00ne said, you can target the links in the list because you are now targeting the list. just add a after the ul to do that. here is how.

header nav ul a {
    list-style: none;
    text-decoration: none;
    color: black;
  }
  <header>
    <nav>
      <ul>
        <li><a href="#">Home</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Blog</a></li>
        <li><a href="#">Contact</a></li>
      </ul>
    </nav>
  </header>

Related