first-child pseudo-class
The first-child pseudo-class selects
an element that is the first child of its
parent.
Syntax
selector:first-child {
}
Example
In this example, we will make the one li
that is the first child of its parent (the first
inside ol) red:
<ol>
<li>list item</li>
<li>list item</li>
<li>list item</li>
<li>list item</li>
<li>list item</li>
</ol>
li:first-child {
color: red;
}
: