CSS Reference Pseudo-class

:first f4m2d

:first is a CSS pseudo-class selector used to select the first page of a printed document. 404t73

It is used in conjunction with the @page, :first acts kind of like a filter used to select only the first page among all pages.

@page :first {
    /* styles for the first page */
}
                

Styles specified in a :first @page rule that has no pseudo-class specified.

In addition to :first, a :right, which select the left and right pages in double-sided documents, respectively.

Styles specified in a :first @page rules.

It is important to note that you cannot change all CSS properties inside an @rule. See the @page entry for more information on what styles can be changed and/or applied.

All pages are automatically classified by agents into either the page break before the first generated box.

If a forced break occurs before the first generated box, it is undefined in CSS 2.1 whether :first applies to the blank page before the break or to the page after it.

Official Syntax 55184y

The :first pseudo-class selector is used in conjunction with the @page rule like so:

@page :first {
    /* styles for the first page go here... */
}
                

Examples 3e5p5z

/* All margins set to 2cm */
@page { 
    margin: 2cm; 
} 

/* Top margin on first page 10cm */
@page :first {
  margin-top: 10cm;    
}
                

Browser k5t66

The :first pseudo-class selector is ed in Internet Explorer 8+ and in Opera 9.2+. It is not ed in Firefox. in other browsers is to be determined.

Written by

Last updated June 3, 2020 at 12:34 pm by Mary Lou

Do you have a suggestion, question or want to contribute? Submit an issue.