close window

Contextual selectors are very selective.

This example shows how to target a specific EM tag using the document hierarchy.

Tags only need to be descendants in the order stated in the selector; other tags can be in between and the selector still works.

In this example, all EM tags are indiscriminately styled as orange text.

em {color: orange;}
<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 listed</em> in the selector </span>; other tags can be in between and the selector still works. </p>