What is the recommended method for adding borders between children of various elements within a div?
In the example below, there should be borders between p,div and div,img.
<div id="list">
<p>child 1</p>
<div>child 2</div>
<img src="">
</div>
If all the children were div
,
#list > div~div { border-top: 1px solid black }
would suffice. However, with different elements, this approach seems challenging. I tried #list > ̃ { border-top: 1px solid black }
without success. Nonetheless, #list > :not(:first-child) { border-top: 1px solid black }
worked. Although it's functional, I'm curious if there is a more efficient solution?