DOM snippet
ul.this>li>ul ->match
ul.this>li>div>ul ->match
ul.this>li>div>div>ul ->match
ul.this>li>div>menu>div>nav>div>div>div>div>ul ->match
ul.this>li>ul>li>div>ul ->dont match
ul.this>li>div>ul>li>div>ul ->dont match
Is there a better way in CSS than stating:
ul.this>li>ul, ul.this>li>:not(ul)>ul, ul.this>li>:not(ul)>:not(ul)>ul,
ul.this>li>:not(ul)>:not(ul)>:not(ul)>ul,
ul.this>li>:not(ul)>:not(ul)>:not(ul)>:not(ul)>ul,
ul.this>li>:not(ul)>:not(ul)>:not(ul)>:not(ul)>:not(ul)>ul
…as that will still fail the n+1 case, but you have to end somewhere. Something like /(ul)+/ in regex?
Read:
Any ul inside and descending ul.this that has in its path from ul.this to the resulting ul no other ul in between.
li>ul,li>:not(ul....matches ul descendants of anyli. That matters because in valid HTML, all children ofulelements that can themselves contain aulelement must be anlielement. So aulelement that's a descendant of aulelement that's a descendant of a givenli- something that you don't want to match - will, by necessity be the descendant of a differentlithat doesn't have an interveningulelement.#myli ul:not(#myli ul ul)