Child Selectors

Child tag is a direct descendant of an enclosing tag. If you want to write a rule so that the tag you're targeting has to be a child of a particular tag, then you can do that too, using the > symbol like this:

<p style= "p > em {color:green;}">

for example if you have this code,

<h1>Contextual selectors are <em>very</em> selective.<h1>

<p>This example shows how to target a <em>specific</em> tag using the document hierarchy.</p>

<p>Tags only need to be descendants <span>in the <em>order stated</em> in the selector</span>; other tags can be in between and the selector still works.</p>

 

just the word specific will be targeted without affecting the other em text. Because "specific" is contained in an em tag that is a child of a p tag.