In the code below, I want to apply a blue background only to the element with the text "blue" (which is a child of the element #hello
), but not any other elements that have that class (here: "not blue!").
#hello>*.setcolor
is my (failed) attempt to say "for the element with id hello
, apply the style to any child element that has the class setcolor
.
#hello>*.setcolor {
background-color: blue;
}
<div id="hello">
<div>
<div class="setcolor">
blue
</div>
</div>
</div>
<div class="setcolor">
not blue!
</div>