Working Draft · css-page

CSS Paged Media

1 property, 17 at-rules defined by this specification, 2 of them known to at least one browser (the others are badged Not in any browser yet).

Each feature in detail

page

Property Baseline: newly availablesince December 2024 Modern CSS: Page setup

MDN The page CSS property is used to specify the named page, a specific type of page defined by the @page at-rule.

Live preview Example from MDN
@page toc {
  size: a4 portrait;
  @top-center {
    content: "Table of contents";
  }
}

@page foreword {
  size: a4 portrait;
  @top-center {
    content: "Foreword";
  }
}

@page introduction {
  size: a4 portrait;
  @top-center {
    content: "Introduction";
  }
}

@page conclusion {
  size: a4 portrait;
  @top-center {
    content: "Conclusion";
  }
}

@page chapter {
  size: a4 landscape;
  @top-center {
    content: "Chapter";
  }
}

fieldset {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  gap: 1rem;
  width: fit-content;
}
body {
  font: 1.1em sans-serif;
}

@media print {
  fieldset {
    display: none;
  }
  section {
    font-size: 2rem;
    font-family: "Roboto", sans-serif;
  }
  .chapter {
    border: tomato 2px solid;
  }
  [data-print="grouped"] > #toc,
  [data-print="paged"] > #toc {
    page: toc;
    font-family: "Courier New";
  }
  [data-print="grouped"] > #foreword,
  [data-print="paged"] > #foreword {
    page: foreword;
    font-family: "Courier New";
  }
  [data-print="grouped"] > #introduction,
  [data-print="paged"] > #introduction {
    page: introduction;
    font-family: "Courier New";
  }
  [data-print="grouped"] > #conclusion,
  [data-print="paged"] > #conclusion {
    page: conclusion;
    font-family: "Courier New";
  }
  [data-print="grouped"] > .chapter,
  [data-print="paged"] > .chapter {
    page: chapter;
  }
  [data-print="paged"] > .chapter {
    border: none;
    break-after: page;
  }
  .chapter > ul {
    columns: 2;
  }
}

Syntax

auto | <custom-ident>

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
boxes that create class A break points
Inherited
no (but see prose)
Percentages
n/a
Computed value
specified value
Canonical order
per grammar
Animation type
discrete

Browser support

First browser version supporting page
Chrome 85
Edge 85
Firefox 110
Safari 1
Chrome Android 85
Safari iOS 1

First version with support, from MDN browser-compat-data.

@bottom-center

At-rule Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

/* for @page */
@bottom-center { <declaration-list> };

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Defined for

@page

This feature only appears in the context of these properties, functions or types.

@bottom-left

At-rule Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

/* for @page */
@bottom-left { <declaration-list> };

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Defined for

@page

This feature only appears in the context of these properties, functions or types.

@bottom-left-corner

At-rule Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

/* for @page */
@bottom-left-corner { <declaration-list> };

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Defined for

@page

This feature only appears in the context of these properties, functions or types.

@bottom-right

At-rule Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

/* for @page */
@bottom-right { <declaration-list> };

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Defined for

@page

This feature only appears in the context of these properties, functions or types.

@bottom-right-corner

At-rule Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

/* for @page */
@bottom-right-corner { <declaration-list> };

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Defined for

@page

This feature only appears in the context of these properties, functions or types.

@left-bottom

At-rule Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

/* for @page */
@left-bottom { <declaration-list> };

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Defined for

@page

This feature only appears in the context of these properties, functions or types.

@left-middle

At-rule Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

/* for @page */
@left-middle { <declaration-list> };

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Defined for

@page

This feature only appears in the context of these properties, functions or types.

@left-top

At-rule Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

/* for @page */
@left-top { <declaration-list> };

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Defined for

@page

This feature only appears in the context of these properties, functions or types.

@page

At-rule Baseline: newly availablesince December 2024 Modern CSS: Page setupModern CSS: page-orientation

Spec Authors can specify various aspects of a page box, such as its dimensions, orientation, and margins, within an @page rule. @page rules are allowed wherever rule-sets are allowed. An @page rule consists of the keyword @page, an optional comma-separated list of page selectors and a block of declarations (said to be in the page context). An @page rule can also contain other at-rules, interleaved between declarations. The current level of this specification only allows margin at-rules inside @page.

MDN The @page at-rule is a CSS at-rule used to modify different aspects of printed pages. It targets and modifies the page's dimensions, orientation, and margins. The @page at-rule can be used to target all pages in a print-out or a subset using its various pseudo-classes.

Live preview Example from MDN
@page {
  size: landscape;
  margin: 2cm;
}

section {
  page-break-after: always;
  break-after: page;
}

@media print {
  button {
    display: none;
  }
}

body {
  font-family: "Helvetica", sans-serif;
  background-color: silver;
}

article {
  width: 100%;
}

section {
  display: grid;
  background-color: white;
  border-radius: 0.6rem;
  justify-items: center;
  padding: 1rem;
  width: 50%;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
  margin: 0 auto;
  margin-block-end: 1rem;
  border: 1px dashed;
}

Syntax

@page <page-selector-list>? { <declaration-rule-list> }

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting @page
Chrome 2
Edge 12
Firefox 19
Safari 18.2
Chrome Android 18
Safari iOS 18.2

First version with support, from MDN browser-compat-data.

Descriptors

bleed
auto | <length> Initial: auto
marks
none | [ crop || cross ] Initial: none
page-margin-safety
none | clamp | add Initial: auto
page-orientation
upright | rotate-left | rotate-right Initial: upright
size
<length [0,∞]>{1,2} | auto | [ <page-size> || [ portrait | landscape ] ] Initial: auto

@right-bottom

At-rule Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

/* for @page */
@right-bottom { <declaration-list> };

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Defined for

@page

This feature only appears in the context of these properties, functions or types.

@right-middle

At-rule Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

/* for @page */
@right-middle { <declaration-list> };

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Defined for

@page

This feature only appears in the context of these properties, functions or types.

@right-top

At-rule Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

/* for @page */
@right-top { <declaration-list> };

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Defined for

@page

This feature only appears in the context of these properties, functions or types.

@top-center

At-rule Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

/* for @page */
@top-center { <declaration-list> };

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Defined for

@page

This feature only appears in the context of these properties, functions or types.

@top-left

At-rule Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

/* for @page */
@top-left { <declaration-list> };

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Defined for

@page

This feature only appears in the context of these properties, functions or types.

@top-left-corner

At-rule Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

/* for @page */
@top-left-corner { <declaration-list> };

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Defined for

@page

This feature only appears in the context of these properties, functions or types.

@top-right

At-rule Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

/* for @page */
@top-right { <declaration-list> };

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Defined for

@page

This feature only appears in the context of these properties, functions or types.

@top-right-corner

At-rule Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

/* for @page */
@top-right-corner { <declaration-list> };

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Defined for

@page

This feature only appears in the context of these properties, functions or types.