How to select following siblings using CSS selectors?

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>

Provided by Scrapfly

This knowledgebase is provided by Scrapfly — a web scraping API that allows you to scrape any website without getting blocked and implements a dozens of other web scraping conveniences. Check us out 👇