Open In App

Explain the purpose of using the CSS box-sizing Property

In CSS, targeting only the first child of an element is useful for applying styles exclusively to the first child element within a container. The :first-child pseudo-class is used to select and style the first child element.

Syntax

/* Selecting and styling the first <p> element within a container */
.container p:first-child {
font-weight: bold;
}

/* Selecting and styling the first child of any type within a container */
.container :first-child {
color: red;
}

Features

Article Tags :