It is because that +
selector is only targeting next element, when ~
is targeting all next div's
in your case. So your CSS will be like something similar to this :.hei:hover~div
.
Here you can find more information about this behavior.
Difference between the selectors div + p (plus) and div ~ p (tilde)
ul ~ p {
color: red;
}
This sibling combinator is similar to X + Y, however, it's less
strict. While an adjacent selector (ul + p) will only select the first
element that is immediately preceded by the former selector, this one
is more generalized. It will select, referring to our example above,
any p elements, as long as they follow a ul.
The second tip: don't use https://www.w3schools.com/ for learning, it has poor examples and did not really cover all the informations.
Instead go for https://developer.mozilla.org/en-US/