The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] Another tricky :nth-child question

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #30748

    Here you go:

    Let’s say we have a the same nav bar made with one main ul and several li’s and inside those li’s there is a nested ul with its li’s:

    We then have a first level of li’s and then a second level of li’s.

    How do you select all the li’s from the first level only without having to add a class to each one?

    Here’s the link to the first question:


    Well, if the ul holding everything had an id or class. you could just go:

    ul#id > li

    That’ll target only the the next level elements. You don’t even need to use nth-child.


    The CHILD SELECTOR! Doh!… My brain is fried, no question about it.

    I was SO fixed on :nth-child…

    Thanks amigo noahgelman :)

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.