<ol>
    <li>li</li>
    <li>li</li>
    <li>li</li>
    <li>li</li>
</ol>
li:first-child {
    background-color: yellowgreen;
}
Rendered Output
:first-child {
    /* ... */
}
<article>
    <h2>Heading Element</h2>
    <p>Paragraph 1</p>
    <p>Paragraph 2</p>
</article>
article h2:first-child {
    background-color: yellowgreen;
}
Rendered Output
<article>
    <div>This 'div' is the first one.</div>
    <div>This <span>nested 'span' is the first one.</span>!</div>
    <div>
        This <em>nested 'em' is the first one.</em>, but this <em>nested 'em' is the last one.</em>!
    </div>
    <div>This <span>nested 'span' is styled.</span>!</div>
    <p>This 'p' is not the first child.</p>
    <div>This 'div' is the last one.</div>
</article>
article *:first-child {
    background-color: yellowgreen;
}
Rendered Output

Last updated: 2025-09-24

See more details on caniuse.com.