DEV Community

Discussion on: CSS: select first-of-class with the subsequent sibling combinator

Collapse
 
philnash profile image
Phil Nash

That doesn’t do the same, notably the + combinator is the direct sibling, so if you throw another <div> in the middle with a different class it breaks.

Collapse
 
equinusocio profile image
Mattia Astorino • Edited

Yes i know. But both solutions have caveats since even with the subsequent sibling the code will break if you use another element type (because you are bound to type of the element).

BTW, nice exploration, thank you :)