I have found two selectors
div p
and
div>p
What is the exact difference between these two css selectors?
I have found two selectors
div p
and
div>p
What is the exact difference between these two css selectors?
p
anywhere inside div
div p {
color: red;
}
<div>
Div
<p>Child</p>
<aside>
<p>Grandchild</p>
</aside>
</div>
p
directly under div
div > p {
color: red;
}
<div>
Div
<p>Child</p>
<aside>
<p>Grandchild</p>
</aside>
</div>
div p
this style will select all the p elements under the div whether the p is inside another div.
The div>p
will only select the p which are under the div. if there is another div into the same div which has p element as well it will not select that p.
P
`; `div#root > p` will not select it.
– Amadan Jul 10 '18 at 06:29