mozilla

Revision 359057 of @page

  • Revision slug: CSS/@page
  • Revision title: @page
  • Revision id: 359057
  • Created:
  • Creator: FredB
  • Is current revision? No
  • Comment Fixed space in code tag

Revision Content

{{CSSRef}}

Summary

The @page CSS at-rule is used to modify some CSS properties when printing a document. You can't change all CSS properties with @page. You can only change the margins, orphans, widows, and page breaks of the document. Attempts to change any other CSS properties will be ignored.

The @page at-rule can be accessed via the CSS object model interface {{domxref("CSSPageRule")}}.

Note: The W3C is discussing how to handle viewport-related {{xref_csslength}} units, vh, vw, vmin, and vmax. Meanwhile do not use them within a @page at-rule.

Syntax

@page :pseudo-class {
  margin:2in;
}

Examples

Please refer to the various pseudo-classes of @page for examples.

  • {{Cssxref(":first")}}
  • {{Cssxref(":left")}}
  • {{Cssxref(":right")}}

Specifications

Specification Status Comment
{{SpecName('CSS3 Paged Media', '#at-page-rule', '@page')}} {{Spec2('CSS3 Paged Media')}} No change from {{SpecName('CSS2.1')}}, though more CSS at-rules can be used inside a @page.
{{SpecName('CSS2.1', 'page.html#page-selectors', '@page')}} {{Spec2('CSS2.1')}}  

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 2.0 {{CompatGeckoDesktop("19.0")}} 8.0 6.0 5.0
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatUnknown}} {{CompatGeckoMobile("19.0")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

See also

  • {{CSS_at_rules}}

Revision Source

<div>
  {{CSSRef}}</div>
<h2 id="Summary">Summary</h2>
<p class="note">The <code>@page</code> CSS at-rule is used to modify some CSS properties when printing a document.<strong> </strong>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 class="note">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 {{xref_csslength}} 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="Syntax">Syntax</h2>
<pre class="syntaxbox">
@page :pseudo-class {
&nbsp; margin:2in;
}
</pre>
<h2 id="Examples">Examples</h2>
<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(":first")}}</li>
  <li>{{Cssxref(":left")}}</li>
  <li>{{Cssxref(":right")}}</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('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>&nbsp;</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{CompatibilityTable}}</p>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>2.0</td>
        <td>{{CompatGeckoDesktop("19.0")}}</td>
        <td>8.0</td>
        <td>6.0</td>
        <td>5.0</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Mobile</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatGeckoMobile("19.0")}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="See_also">See also</h2>
<ul>
  <li>{{CSS_at_rules}}</li>
</ul>
Revert to this revision