1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
---
title: '@page'
slug: Web/CSS/@page
tags:
- '@page'
- At-rule
- CSS
- Layout
- NeedsTranslation
- Reference
- TopicStub
- Web
translation_of: Web/CSS/@page
---
<div>{{CSSRef}}</div>
<p>The <strong><code>@page</code></strong> CSS at-rule is used to modify some CSS properties when printing a document.</p>
<h2 id="Syntax">Syntax</h2>
<pre class="brush: css no-line-numbers notranslate">@page {
margin: 1cm;
}
@page :first {
margin: 2cm;
}</pre>
<h3 id="Descriptors">Descriptors</h3>
<dl>
<dt><a href="/en-US/docs/Web/CSS/@page/size"><code>size</code></a></dt>
<dd>Specifies the target size and orientation of the page box’s containing block. In the general case, where one page box is rendered onto one page sheet, it also indicates the size of the destination page sheet.</dd>
</dl>
<dl>
<dt><a href="/en-US/docs/Web/CSS/@page/marks"><code>marks</code></a></dt>
<dd>Adds crop and/or registration marks to the document.</dd>
</dl>
<dl>
<dt><a href="/en-US/docs/Web/CSS/@page/bleed"><code>bleed</code></a></dt>
<dd>Specifies the extent beyond the page box at which the page rendering is clipped.</dd>
</dl>
<h2 id="Description">Description</h2>
<p>You can't change all CSS properties with <code>@page</code>. You can only change the margins, orphans, widows, and page breaks of the document. Attempts to change any other CSS properties will be ignored.</p>
<p>The <code>@page</code> at-rule can be accessed via the CSS object model interface {{domxref("CSSPageRule")}}.</p>
<div class="note"><strong>Note:</strong> The W3C is discussing how to handle viewport-related {{cssxref("<length>")}} units, <code>vh</code>, <code>vw</code>, <code>vmin</code>, and <code>vmax</code>. Meanwhile do not use them within a <code>@page</code> at-rule.</div>
<h2 id="Formal_syntax">Formal syntax</h2>
<pre class="syntaxbox notranslate">{{csssyntax}}</pre>
<h2 id="Examples">Examples</h2>
<h3 id="page_pseudo-class_examples">@page pseudo-class examples</h3>
<p>Please refer to the various <a href="/en-US/docs/CSS/Pseudo-classes" title="Pseudo-classes">pseudo-classes</a> of <code>@page</code> for examples.</p>
<ul>
<li>{{Cssxref(":blank")}}</li>
<li>{{Cssxref(":first")}}</li>
<li>{{Cssxref(":left")}}</li>
<li>{{Cssxref(":right")}}</li>
<li>{{Cssxref(":recto")}} {{experimental_inline}}</li>
<li>{{Cssxref(":verso")}} {{experimental_inline}}</li>
</ul>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('CSS Logical Properties', '#page', ':recto and :verso')}}</td>
<td>{{Spec2('CSS Logical Properties')}}</td>
<td>Adds the <code>:recto</code> and <code>:verso</code> page selectors</td>
</tr>
<tr>
<td>{{SpecName('CSS3 Paged Media', '#at-page-rule', '@page')}}</td>
<td>{{Spec2('CSS3 Paged Media')}}</td>
<td>No change from {{SpecName('CSS2.1')}}, though more CSS at-rules can be used inside a <code>@page</code>.</td>
</tr>
<tr>
<td>{{SpecName('CSS2.1', 'page.html#page-selectors', '@page')}}</td>
<td>{{Spec2('CSS2.1')}}</td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{Compat("css.at-rules.page")}}</p>
<h2 id="See_also">See also</h2>
<ul>
<li>See the <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=286443">[META] CSS Paged Media Module Level 3</a> ticket in Bugzilla for tracking progress on the subject (page-based counters, etc.)</li>
</ul>
|