Child vs direct child : Level Selector « Style Basics « HTML / CSS






Child vs direct child

  

<html>
 <head>
  <title></title>
<style type="text/css">
p > strong {
  text-decoration: underline;
} 
</style>
<body>
<div>
 <p>Nothing happens to this part of the sentence because this 
<strong>strong</strong> isn't the direct child of div.</p> 
 However, this <strong>strong</strong> is the child of div. 
Therefore, it receives the style dictated in the CSS rule.
</div>
<body>

   
    
  








Related examples in the same category

1.Set style for paragraph in a blockquote
2.LI under UL which are in a DIV
3.Three level nested for tag names
4.Set anchor in LI under UL which are in a DIV
5.tag name.class name