Suppose I have 3 levels of HTML tag elements in a parent child relationship. A is a grandparent. Inside that there is a tag(parent) and inside that tag there is a
tag(child).Now by using CSS I want to change the design of that
(child) tag from the (grandparent) tag using CSS selectors from that (grandparent) id or class name.
Need help on this css trick
<div>
Hi I am grandparent.
<h2>
Hi I am parent.
<p> Hi I am child. </p>
</h2>
<h2>
Hi I am parent.
<p> Hi I am child. </p>
</h2>
<h2>
Hi I am parent.
<p> Hi I am child. </p>
</h2>
<h2>
Hi I am parent.
<p> Hi I am child. </p>
</h2>
<h2>
Hi I am parent.
<p> Hi I am child. </p>
</h2>
</div>
I want the result to be as follows: Make the background color of the
tag to any colour only for the 4th parent. Note that the control should be from the grandparent. This is because I have a *ngfor in the grandparent and I want to write the css for that using nth-child(n) concept.