🚀 We are hiring! See open positions

How to select following siblings using CSS selectors?

by scrapecrow Apr 20, 2023

To select the following sibling (i.e. sibling that is below the current element) the + and ~ combinators can be used.

The ~ selects any following general sibling:

<article> <p>ignore</p> <p class="ad">ignore</p> <p>select</p> <p>select</p> </article>

The + selects one following adjacent sibling (i.e. has to be right below it):

<article> <p>ignore</p> <p class="ad">ignore</p> <p>select</p> <p>ignore</p> </article>

Related Articles