Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

CSS property `page`

`page` assigns a named page type to a box that generates a class A break point; during pagination, the matching `@page` rule defines the page on which that box starts.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

auto | <custom-ident>

page assigns a named page type to a box that generates a class A break point; during pagination, the matching @page rule defines the page on which that box starts.

The example assigns Invoice to one section, leaves another at auto, and reads both computed values plus the named rule selector and size through CSSOM.

Grammar: auto | <custom-ident>.

Page names are case-sensitive, while the auto keyword is not. Its used value comes from the nearest ancestor with a non-auto name, and different names on either side of a break point can force a new page.

Examples

<!doctype html><meta charset="utf-8"><style id="rules">@page Invoice { size:120mm 80mm; margin:10mm } #target { page:Invoice } #automatic { page:auto }</style><section id="target">invoice</section><section id="automatic">automatic</section><pre id="result"></pre><script>const pageRule=[...rules.sheet.cssRules].find(rule=>rule.constructor.name==='CSSPageRule'),targetValue=getComputedStyle(target).page,autoValue=getComputedStyle(automatic).page,selector=pageRule.selectorText,size=pageRule.style.size,supported=CSS.supports('page','Invoice');if(targetValue!=='Invoice'||autoValue!=='auto'||selector!=='Invoice'||size!=='120mm 80mm'||!supported)throw new Error('named-page CSSOM mismatch');result.textContent='computed='+targetValue+'; auto='+autoValue+'; rule='+selector+'; size='+size+'; supported='+supported;</script>

Result

computed=Invoice; auto=auto; rule=Invoice; size=120mm 80mm; supported=true

The example assigns `Invoice` to one section, leaves another at `auto`, and reads both computed values plus the named rule selector and size through CSSOM.

Sources