Forums

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

Home Forums CSS What is the Rule Here?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #26980
    cybershot
    Participant

    I never really did understand the order in css selection. or maybe I just forgot. I was just trying to set my nav to disply inline and it wouldn’t work, I did get it, but I tried

    #nav ul li { display: inline; }

    This did not work. I had to use

    ul#nav li

    Why did I need to do it that way? What is the rule here?

    #67238
    AshtonSanders
    Participant

    ul#nav selects a UL with the ID=nav

    #nav ul selects a UL that is nested inside another element with the ID=nav.

    *shameless advertising* Here’s a short CSS Selector Tutorial I made on how selectors work.

    #67261
    TheDoc
    Member

    #nav ul li =

    Code:

    ul#nav li =

    Code:

    ul#nav li could also simply be written like this: #nav li

    #67284
    jinfiesto
    Member

    Here’s how those selectors work. The space is basically referring to nested elements, so div#cheese p can be read as "p inside of the div with the id of cheese". If you want to say for instance, "div with the id of cheese", it’s written as above ie div#cheese. Also, this works for classes, so div.cheese would be read as "div with the class of cheese". Does that make sense?

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