When we need to select any
sibling element that follow
a particular element, we use
the ~
character to combine
two selectors like this:
h1 ~ p
will select
all the p
elements that come
after an h1
element
within the same
parent element.
This will select all descendant p
elements too.
The p
element should be after the
h1
element and should be a direct child or a
descendant of the parent of the h1
element:
The first p
element is not
selected because it does not
come after h1
. And the last
p
element is not selected
because it is not within
the same parent element as h1
.