The first-child pseudo-class

The first-child pseudo-class selects an element that is the first child of its parent.

Syntax

cssselector: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:

html<ol>
  <li>list item</li>
  <li>list item</li>
  <li>list item</li>
  <li>list item</li>
  <li>list item</li>
</ol>
cssli:first-child {
  color: red;
}

Результат: