I'm working with CSS' display:contents paired with element>elementselector.
As for the definition, the display:contents property:
Makes the container disappear, making the child elements children of the element the next level up in the DOM
So I have this example code:
.wrapper {
background-color: red;
}
.hidden {
display: contents;
}
.wrapper > .child {
background-color: yellow;
}
<div class='wrapper'>
<div class='hidden'>
<div class='child'>I'm a child</div>
<div class='child'>I'm a child</div>
</div>
<div class='child'>I'm a child</div>
<div class='child'>I'm a child</div>
</div>
I was expecting to have all the childrens with yellow background, because the element>element selector should target them all (they are all at the same level when the property display:contents comes into play).
Why is this not the case? Is the CSS unable to target children in this way?