Now of ed if i declare something like
p ~ ul
what this is really doing is "Selecting every P that precedes a ul" , now that was pretty simple to understand and sounded easy to implement until i came across This Fiddle and well if you do have a look at it , you will see that the final list is precedeed by a "" , now why is it applying the selection to the "ul preceeded by a h2" when it should only be applying the selection to a "ul preceeded by a p" ?
Thank you .
Hi gautamz07, The second UL
The second UL is still preceded by the P.
It's called a general selector so it targets all elements on the same level, siblings that come after the P.
To get the result you were expecting try Adjacent sibling selector +
Tony i am aware of adjacent selectors , and after reading a bit more of ~ selector i got the reason why , the second set of "UL" tags were selected too . Now my question is whats the practical use of something like ~ selector , would't it be dangerous to select something like that ? unless ur absolutely certain you want everything thats preceded by ~ to be selected , and that would be a rare case scenario . Is it practically even used ?