简体   繁体   中英

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

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>

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM