So I'm learning CSS right now. I'm tinkering with selectors at the moment and this has me kind of stumped. When I run this code. The child of the li all stay green.
ul li{
color: green;
}
li > ol{
color: red;
}
But if I run this code, it works the way I intended the first one to work. I understand why the second code works. I'm just wondering why they both don't do the same thing.I believe ol is the child of the li, so why doesn't it change colors?
ul > li{
color: green;
}
li ol{
color: red;
}
HTML code:
<ul>
<li>Peter<ol>
<li>Juan</li>
<li>Samuel</li>
</ol></li>
<li>John<ol>
<li>Juan</li>
<li>Samuel</li>
</ol></li>
<li>Sara<ol>
<li>Juan</li>
<li>Samuel</li>
</ol></li>
</ul>