O'Reilly logo

CSS Pocket Reference, 4th Edition by Eric A. Meyer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

:first-child

Applies to:

Any element

Description:

Matches an element when it is the first child of another element. Thus, div:first-child will select any div that is the first child of another element, not the first child element of any div.

Examples:

td:first-child {border-left: 1px solid;}
p:first-child {text-indent: 0; margin-top: 2em;}

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required