I have the following HTML:
<html>
<body>
<div id="parent">
<div>
<div>A</div>
<div>A</div>
<div>A</div>
</div>
<div>
<div>A</div>
<div>A</div>
<div>A</div>
</div>
<div>
<div>A</div>
<div>A</div>
<div>A</div>
</div>
</div>
</body>
</html>
and the following CSS:
#parent div:nth-child(2) {
background-color: blue;
}
I was expecting the fourth, fifth, and sixth "A"s to be blue since I was trying to target only the second child of the element with ID parent, however, the second and eighth were also made blue. Why is this and how do I fix it?
Here is an image of my result: https://i.stack.imgur.com/FEB4N.png
And here is an image of my expected result: https://i.stack.imgur.com/MVrCn.png