CSS :first

The :first pseudo-class applies to the first page in paged media, usually inside an @page rule for print styles. It does not select the first child element in a container.

Syntax

@page :first {
  margin-top: 4rem;
}

Example

@media print {
  @page :first {
    margin-top: 5rem;
  }
}
Result:

This rule affects printed output, not the live screen layout.

Important note

If you want the first element inside a parent, use :first-child or :first-of-type instead.