CSS sibling selectors (select all siblings) [duplicate]

You can select all the following siblings using ~ instead of +:

.open ~ h2

If you need to select all h2 elements that aren’t .open whether they precede or follow .open, there is no sibling combinator for that. You’ll need to use :not() instead:

h2:not(.open)

Optionally with a child combinator if you need to limit the selection to div parents:

div > h2:not(.open)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)