大网数据广告活动
Web 标准与前端开发

`size` CSS at-rule descriptor

· 52CE 我爱测

The **`size`** CSS at-rule descriptor, used with the @page at-rule, defines the size and orientation of the box which is used to represent a page. Most of the time, this size corresponds to the target size of the printed page if applicable.

The size CSS at-rule descriptor, used with the @page at-rule, defines the size and orientation of the box which is used to represent a page. Most of the time, this size corresponds to the target size of the printed page if applicable.

Size may either be defined with a "scalable" keyword (in this case the page will fill the available dimensions) or with absolute dimensions.

Syntax

/* Keyword values for scalable size */
size: auto;
size: portrait;
size: landscape;

/* <length> values */
/* 1 value: height = width */
size: 6in;

/* 2 values: width then height */
size: 4in 6in;

/* Keyword values for absolute size */
size: A4;
size: B5;
size: JIS-B4;
size: letter;

/* Mixing size and orientation */
size: A4 portrait;

Values

  • auto
    • : The user agent decides the size of the page. In most cases, the dimensions and orientation of the target sheet are used.
  • landscape
    • : The content of the page is displayed in landscape mode (i.e., the longest side of the box is horizontal).
  • portrait
    • : The content of the page is displayed in portrait mode (i.e., the longest side of the box is vertical). This is the default orientation.
  • <length>
    • : Any length value (see <length>). The first value corresponds to the width of the page box and the second one corresponds to its height. If only one value is provided, it is used for both width and height.
  • <page-size>
    • : A keyword which may be any of the following values:
      • A5
        • : This matches the standard, ISO dimensions: 148mm x 210mm.
      • A4
        • : This matches the standard, ISO dimensions: 210mm x 297mm. (most frequently used dimensions for personal printing.)
      • A3
        • : This matches the standard, ISO dimensions: 297mm x 420mm.
      • B5
        • : This matches the standard, ISO dimensions: 176mm x 250mm.
      • B4
        • : This matches the standard, ISO dimensions: 250mm x 353mm.
      • JIS-B5
        • : This correspond to the JIS standard dimensions: 182mm x 257mm.
      • JIS-B4
        • : This correspond to the JIS standard dimensions: 257mm x 364mm.
      • letter
        • : This keyword is an equivalent to the dimensions of letter paper in North America i.e., 8.5in x 11in.
      • legal
        • : This keyword is an equivalent to the dimensions of legal papers in North America i.e., 8.5in x 14in.
      • ledger
        • : This keyword is an equivalent to the dimensions of ledger pages in North America i.e., 11in x 17in.

Formal definition

Formal syntax

Examples

Specifying size and orientation

@page {
  size: A4 landscape;
}

Specifying a custom size

@page {
  size: 4in 6in;
}

Nesting inside a @media rule

@media print {
  @page {
    size: 50mm 150mm;
  }
}

Specifications

Browser compatibility

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。