0

I've learned that if I'm refering to a <li> within <ul> or <ol> in CSS i should use ol > li or ul > li but once i forgot put the sign between ol and li and I've found that is working anyway. What is the proper way to do this?

j08691
  • 204,283
  • 31
  • 260
  • 272
Luke_Nuke
  • 461
  • 2
  • 6
  • 23
  • https://stackoverflow.com/questions/4459821/css-selector-what-is-it – Michael Coker Jun 17 '17 at 19:04
  • 2
    Possible duplicate of [What does the ">" (greater-than sign) CSS selector mean?](https://stackoverflow.com/questions/3225891/what-does-the-greater-than-sign-css-selector-mean) – jonrsharpe Jun 17 '17 at 19:05

4 Answers4

2

Yes it works, because it "Selects all direct child elements specified by “child” of elements specified by “parent”"

like

<ul>
<li></li>
</ul>

but not
<ul>
<li>
   <ol>
      <li></li>
   </ol>
</li>
</ul>

when you use ul > li selector, it will get only one direct child li element on ex.2, if used ul li then you will get tow li elements - all child li elements of ul

  • So in 2nd example: It will get only one
  • element or all
  • elements that are childs of
      so it will het all
    • from
        and all
      • from
          since
            is also its child so in conesequence all within
              are also its childs?
  • – Luke_Nuke Jun 17 '17 at 19:14
  • ul > li means direct child element, so in ex.2 it will get direct li element. ul li withoud > sighn means all ull children elements through all hierarchy and it will get 2 li elements, yes, selond is ol-s direct child but it-s ul-s indirect child but child – lasha maraneli Jun 17 '17 at 19:28