This problem seems very simple, however I cannot get this to work.
I have the following simple markup.
<div id="left_pane">
<ul>
<div id="indicator"></div>
<li>Something</li>
<li>Something else</li>
</ul>
</div>
How can I select the first item from the list that is a li element? (i.e. not the div).
I have tried many different ways… like this
#left_pane ul:first-child li {
/* style */
}
#left_pane li:first-child {
/* style */
}
But I can’t seem to make anything work.
To get the first element of its type regardless of other elements of different types, you’ll normally use the
:first-of-typeCSS3 pseudo-class.But here, it’s not valid HTML to have a
divas a child of aulin the first place, so you ought to move that innerdivout. It should then be enough to use:first-childas per your second rule since aulcan only havelielements as children: