<p>hello
<div>test</div>
</p>
<div>yo
<p>hi</p>
</div>
<p>hello</p>
When I apply the styles below to the code above, I get unexpected results.
p + div {
color:orange;
}
https://i.sstatic.net/3coK1.png
The style targets the div inside the p tag, but I expected it to only target immediate siblings on the same level. However, when I try:
div + p {
color:orange;
}
The paragraph inside the div is not styled as shown here:
https://i.sstatic.net/C8Shd.png
Can anyone explain this behavior?